Browse Source

[http] Profile receive datapath

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
e825a96a25
1 changed files with 13 additions and 0 deletions
  1. 13
    0
      src/net/tcp/httpcore.c

+ 13
- 0
src/net/tcp/httpcore.c View File

53
 #include <ipxe/acpi.h>
53
 #include <ipxe/acpi.h>
54
 #include <ipxe/version.h>
54
 #include <ipxe/version.h>
55
 #include <ipxe/params.h>
55
 #include <ipxe/params.h>
56
+#include <ipxe/profile.h>
56
 #include <ipxe/http.h>
57
 #include <ipxe/http.h>
57
 
58
 
58
 /* Disambiguate the various error causes */
59
 /* Disambiguate the various error causes */
93
 /** Retry delay used when we cannot understand the Retry-After header */
94
 /** Retry delay used when we cannot understand the Retry-After header */
94
 #define HTTP_RETRY_SECONDS 5
95
 #define HTTP_RETRY_SECONDS 5
95
 
96
 
97
+/** Receive profiler */
98
+static struct profiler http_rx_profiler __profiler = { .name = "http.rx" };
99
+
100
+/** Data transfer profiler */
101
+static struct profiler http_xfer_profiler __profiler = { .name = "http.xfer" };
102
+
96
 /** HTTP flags */
103
 /** HTTP flags */
97
 enum http_flags {
104
 enum http_flags {
98
 	/** Request is waiting to be transmitted */
105
 	/** Request is waiting to be transmitted */
892
 	ssize_t line_len;
899
 	ssize_t line_len;
893
 	int rc = 0;
900
 	int rc = 0;
894
 
901
 
902
+	profile_start ( &http_rx_profiler );
895
 	while ( iobuf && iob_len ( iobuf ) ) {
903
 	while ( iobuf && iob_len ( iobuf ) ) {
896
 
904
 
897
 		switch ( http->rx_state ) {
905
 		switch ( http->rx_state ) {
927
 				iob_pull ( iobuf, data_len );
935
 				iob_pull ( iobuf, data_len );
928
 			} else if ( data_len < iob_len ( iobuf ) ) {
936
 			} else if ( data_len < iob_len ( iobuf ) ) {
929
 				/* Deliver partial buffer as raw data */
937
 				/* Deliver partial buffer as raw data */
938
+				profile_start ( &http_xfer_profiler );
930
 				rc = xfer_deliver_raw ( &http->xfer,
939
 				rc = xfer_deliver_raw ( &http->xfer,
931
 							iobuf->data, data_len );
940
 							iobuf->data, data_len );
932
 				iob_pull ( iobuf, data_len );
941
 				iob_pull ( iobuf, data_len );
933
 				if ( rc != 0 )
942
 				if ( rc != 0 )
934
 					goto done;
943
 					goto done;
944
+				profile_stop ( &http_xfer_profiler );
935
 			} else {
945
 			} else {
936
 				/* Deliver whole I/O buffer */
946
 				/* Deliver whole I/O buffer */
947
+				profile_start ( &http_xfer_profiler );
937
 				if ( ( rc = xfer_deliver_iob ( &http->xfer,
948
 				if ( ( rc = xfer_deliver_iob ( &http->xfer,
938
 						 iob_disown ( iobuf ) ) ) != 0 )
949
 						 iob_disown ( iobuf ) ) ) != 0 )
939
 					goto done;
950
 					goto done;
951
+				profile_stop ( &http_xfer_profiler );
940
 			}
952
 			}
941
 			http->rx_len += data_len;
953
 			http->rx_len += data_len;
942
 			if ( http->chunk_remaining ) {
954
 			if ( http->chunk_remaining ) {
985
 	if ( rc )
997
 	if ( rc )
986
 		http_close ( http, rc );
998
 		http_close ( http, rc );
987
 	free_iob ( iobuf );
999
 	free_iob ( iobuf );
1000
+	profile_stop ( &http_rx_profiler );
988
 	return rc;
1001
 	return rc;
989
 }
1002
 }
990
 
1003
 

Loading…
Cancel
Save