From c51ce3387f93d50bb7ba3617529efbf4d7f824ff Mon Sep 17 00:00:00 2001 From: Dmitri Tikhonov Date: Tue, 31 Oct 2017 09:35:58 -0400 Subject: [PATCH] Latest changes - [API Change] Sendfile-like functionality is gone. The stream no longer opens files and deals with file descriptors. (Among other things, this makes the code more portable.) Three writing functions are provided: lsquic_stream_write lsquic_stream_writev lsquic_stream_writef (NEW) lsquic_stream_writef() is given an abstract reader that has function pointers for size() and read() functions which the user can implement. This is the most flexible way. lsquic_stream_write() and lsquic_stream_writev() are now both implemented as wrappers around lsquic_stream_writef(). - [OPTIMIZATION] When writing to stream, be it within or without the on_write() callback, place data directly into packet buffer, bypassing auxiliary data structures. This reduces amount of memory required, for the amount of data that can be written is limited by the congestion window. To support writes outside the on_write() callback, we keep N outgoing packet buffers per connection which can be written to by any stream. One half of these are reserved for the highest priority stream(s), the other half for all other streams. This way, low-priority streams cannot write instead of high-priority streams and, on the other hand, low-priority streams get a chance to send their packets out. The algorithm is as follows: - When user writes to stream outside of the callback: - If this is the highest priority stream, place it onto the reserved N/2 queue or fail. (The actual size of this queue is dynamic -- MAX(N/2, CWND) -- rather than N/2, allowing high-priority streams to write as much as can be sent.) - If the stream is not the highest priority, try to place the data onto the reserved N/2 queue or fail. - When tick occurs *and* more packets can be scheduled: - Transfer packets from the high N/2 queue to the scheduled queue. - If more scheduling is allowed: - Call on_write callbacks for highest-priority streams, placing resulting packets directly onto the scheduled queue. - If more scheduling is allowed: - Transfer packets from the low N/2 queue to the scheduled queue. - If more scheduling is allowed: - Call on_write callbacks for non-highest-priority streams, placing resulting packets directly onto the scheduled queue The number N is currently 20, but it could be varied based on resource usage. - If stream is created due to incoming headers, make headers readable from on_new. - Outgoing packets are no longer marked non-writeable to prevent placing more than one STREAM frame from the same stream into a single packet. This property is maintained via code flow and an explicit check. Packets for stream data are allocated using a special function. - STREAM frame elision is cheaper, as we only perform it if a reset stream has outgoing packets referencing it. - lsquic_packet_out_t is smaller, as stream_rec elements are now inside a union. --- CHANGELOG | 71 + CMakeLists.txt | 6 +- docs/html/annotated.html | 3 +- docs/html/classes.html | 8 +- docs/html/functions.html | 6 + docs/html/functions_vars.html | 6 + docs/html/globals.html | 13 +- docs/html/globals_func.html | 13 +- docs/html/lsquic_8h.html | 113 +- docs/html/lsquic_8h_source.html | 26 +- docs/html/lsquic__types_8h_source.html | 2 +- docs/html/search/all_1.js | 8 +- docs/html/search/classes_0.js | 1 + docs/html/search/functions_0.js | 5 +- docs/html/search/searchdata.js | 2 +- docs/html/search/variables_1.js | 5 +- docs/html/search/variables_2.html | 26 + docs/html/search/variables_2.js | 6 + docs/html/structlsquic__reader.html | 143 ++ include/lsquic.h | 55 +- src/liblsquic/lsquic_arr.c | 7 + src/liblsquic/lsquic_arr.h | 3 + src/liblsquic/lsquic_conn.c | 31 +- src/liblsquic/lsquic_conn_flow.h | 12 +- src/liblsquic/lsquic_conn_public.h | 8 +- src/liblsquic/lsquic_data_in_if.h | 3 + src/liblsquic/lsquic_di_error.c | 8 + src/liblsquic/lsquic_di_hash.c | 21 + src/liblsquic/lsquic_di_nocopy.c | 19 + src/liblsquic/lsquic_engine.c | 2 + src/liblsquic/lsquic_ev_log.c | 9 +- src/liblsquic/lsquic_ev_log.h | 11 +- src/liblsquic/lsquic_frame_reader.c | 11 + src/liblsquic/lsquic_frame_reader.h | 3 + src/liblsquic/lsquic_frame_writer.c | 30 +- src/liblsquic/lsquic_frame_writer.h | 7 +- src/liblsquic/lsquic_full_conn.c | 621 ++--- src/liblsquic/lsquic_handshake.c | 73 +- src/liblsquic/lsquic_handshake.h | 20 +- src/liblsquic/lsquic_hash.c | 9 + src/liblsquic/lsquic_hash.h | 2 + src/liblsquic/lsquic_headers_stream.c | 32 +- src/liblsquic/lsquic_headers_stream.h | 6 + src/liblsquic/lsquic_hpack_dec.c | 21 + src/liblsquic/lsquic_hpack_dec.h | 3 + src/liblsquic/lsquic_hpack_enc.c | 17 + src/liblsquic/lsquic_hpack_enc.h | 3 + src/liblsquic/lsquic_malo.c | 14 + src/liblsquic/lsquic_malo.h | 3 + src/liblsquic/lsquic_mm.c | 35 +- src/liblsquic/lsquic_mm.h | 3 + src/liblsquic/lsquic_packet_in.c | 14 + src/liblsquic/lsquic_packet_in.h | 9 + src/liblsquic/lsquic_packet_out.c | 604 ++++- src/liblsquic/lsquic_packet_out.h | 64 +- src/liblsquic/lsquic_packints.c | 14 + src/liblsquic/lsquic_packints.h | 3 + src/liblsquic/lsquic_parse.h | 5 + src/liblsquic/lsquic_parse_gquic_Q041.c | 9 + src/liblsquic/lsquic_parse_gquic_be.c | 1 + src/liblsquic/lsquic_parse_gquic_common.c | 8 + src/liblsquic/lsquic_parse_gquic_le.c | 1 + src/liblsquic/lsquic_rechist.c | 9 + src/liblsquic/lsquic_rechist.h | 3 + src/liblsquic/lsquic_send_ctl.c | 450 +++- src/liblsquic/lsquic_send_ctl.h | 69 +- src/liblsquic/lsquic_senhist.c | 9 + src/liblsquic/lsquic_senhist.h | 3 + src/liblsquic/lsquic_spi.c | 117 +- src/liblsquic/lsquic_spi.h | 22 +- src/liblsquic/lsquic_stream.c | 1531 +++++------- src/liblsquic/lsquic_stream.h | 100 +- test/http_client.c | 39 +- test/prog.c | 1 - test/test_cert.c | 133 - test/test_cert.h | 27 - test/test_common.c | 76 + test/test_common.h | 13 + test/unittests/CMakeLists.txt | 6 +- test/unittests/test_ackgen_gquic_be.c | 1 + test/unittests/test_ackgen_gquic_ietf.c | 1 + test/unittests/test_ackgen_gquic_le.c | 1 + test/unittests/test_ackparse_gquic_be.c | 1 + test/unittests/test_ackparse_gquic_ietf.c | 1 + test/unittests/test_ackparse_gquic_le.c | 1 + test/unittests/test_elision.c | 18 +- test/unittests/test_frame_chop.c | 17 +- test/unittests/test_frame_rw.c | 16 +- test/unittests/test_frame_writer.c | 43 +- test/unittests/test_packet_out.c | 14 +- test/unittests/test_rechist.c | 2 + test/unittests/test_sfcw.c | 1 + test/unittests/test_spi.c | 254 +- test/unittests/test_stream.c | 2768 ++++++++++++--------- 94 files changed, 4746 insertions(+), 3298 deletions(-) create mode 100644 docs/html/search/variables_2.html create mode 100644 docs/html/search/variables_2.js create mode 100644 docs/html/structlsquic__reader.html delete mode 100644 test/test_cert.c delete mode 100644 test/test_cert.h diff --git a/CHANGELOG b/CHANGELOG index dcfe0e3bb..802d94ac6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,74 @@ +2017-10-31 + + - [API Change] Sendfile-like functionality is gone. The stream no + longer opens files and deals with file descriptors. (Among other + things, this makes the code more portable.) Three writing functions + are provided: + + lsquic_stream_write + lsquic_stream_writev + lsquic_stream_writef (NEW) + + lsquic_stream_writef() is given an abstract reader that has function + pointers for size() and read() functions which the user can implement. + This is the most flexible way. lsquic_stream_write() and + lsquic_stream_writev() are now both implemented as wrappers around + lsquic_stream_writef(). + + - [OPTIMIZATION] When writing to stream, be it within or without the + on_write() callback, place data directly into packet buffer, + bypassing auxiliary data structures. This reduces amount of memory + required, for the amount of data that can be written is limited + by the congestion window. + + To support writes outside the on_write() callback, we keep N + outgoing packet buffers per connection which can be written to + by any stream. One half of these are reserved for the highest + priority stream(s), the other half for all other streams. This way, + low-priority streams cannot write instead of high-priority streams + and, on the other hand, low-priority streams get a chance to send + their packets out. + + The algorithm is as follows: + + - When user writes to stream outside of the callback: + - If this is the highest priority stream, place it onto the + reserved N/2 queue or fail. + (The actual size of this queue is dynamic -- MAX(N/2, CWND) -- + rather than N/2, allowing high-priority streams to write as + much as can be sent.) + - If the stream is not the highest priority, try to place the + data onto the reserved N/2 queue or fail. + - When tick occurs *and* more packets can be scheduled: + - Transfer packets from the high N/2 queue to the scheduled + queue. + - If more scheduling is allowed: + - Call on_write callbacks for highest-priority streams, + placing resulting packets directly onto the scheduled queue. + - If more scheduling is allowed: + - Transfer packets from the low N/2 queue to the scheduled + queue. + - If more scheduling is allowed: + - Call on_write callbacks for non-highest-priority streams, + placing resulting packets directly onto the scheduled queue + + The number N is currently 20, but it could be varied based on + resource usage. + + - If stream is created due to incoming headers, make headers readable + from on_new. + + - Outgoing packets are no longer marked non-writeable to prevent placing + more than one STREAM frame from the same stream into a single packet. + This property is maintained via code flow and an explicit check. + Packets for stream data are allocated using a special function. + + - STREAM frame elision is cheaper, as we only perform it if a reset + stream has outgoing packets referencing it. + + - lsquic_packet_out_t is smaller, as stream_rec elements are now + inside a union. + 2017-10-12 - Do not send RST_STREAM when stream is closed for reading diff --git a/CMakeLists.txt b/CMakeLists.txt index e2a9b0705..02f0ba9c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,11 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") link_directories( /usr/local/lib ) ENDIF() -add_executable(http_client test/http_client.c test/prog.c test/test_common.c test/test_cert.c) +add_executable(http_client + test/http_client.c + test/prog.c + test/test_common.c +) target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m) diff --git a/docs/html/annotated.html b/docs/html/annotated.html index e3ef0b2c1..c30281533 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -94,7 +94,8 @@  Clsquic_logger_if  Clsquic_out_spec  Clsquic_packout_mem_if - Clsquic_stream_ifThe definition of callback functions call by lsquic_stream to process events + Clsquic_reader + Clsquic_stream_ifThe definition of callback functions call by lsquic_stream to process events diff --git a/docs/html/classes.html b/docs/html/classes.html index 916391fd6..021cbd4a9 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -88,10 +88,10 @@
L
- - - + + + +
  l  
-
lsquic_engine_settings   lsquic_http_headers   lsquic_out_spec   lsquic_stream_if   
lsquic_http_header   lsquic_logger_if   lsquic_packout_mem_if   
lsquic_engine_api   
lsquic_engine_settings   lsquic_logger_if   lsquic_reader   
lsquic_http_header   lsquic_out_spec   lsquic_stream_if   
lsquic_engine_api   lsquic_http_headers   lsquic_packout_mem_if   
L
diff --git a/docs/html/functions.html b/docs/html/functions.html index 4783edb75..a3eba6a80 100644 --- a/docs/html/functions.html +++ b/docs/html/functions.html @@ -151,6 +151,12 @@
  • es_versions : lsquic_engine_settings
  • +
  • lsqr_read +: lsquic_reader +
  • +
  • lsqr_size +: lsquic_reader +
  • on_goaway_received : lsquic_stream_if
  • diff --git a/docs/html/functions_vars.html b/docs/html/functions_vars.html index 35bd4c417..8c1e646a5 100644 --- a/docs/html/functions_vars.html +++ b/docs/html/functions_vars.html @@ -151,6 +151,12 @@
  • es_versions : lsquic_engine_settings
  • +
  • lsqr_read +: lsquic_reader +
  • +
  • lsqr_size +: lsquic_reader +
  • on_goaway_received : lsquic_stream_if
  • diff --git a/docs/html/globals.html b/docs/html/globals.html index 2444ebc8a..f5ef2a866 100644 --- a/docs/html/globals.html +++ b/docs/html/globals.html @@ -278,6 +278,9 @@

    - l -