]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
some tuning of buffer/write record sizes
authorStefan Eissing <icing@apache.org>
Thu, 29 Oct 2015 14:38:52 +0000 (14:38 +0000)
committerStefan Eissing <icing@apache.org>
Thu, 29 Oct 2015 14:38:52 +0000 (14:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1711283 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_conn_io.c
modules/http2/h2_session.c

index 34b4c30bf8dfafd0b26392f6fa8df61cf43b30e8..6c194d93067df19fed07f074153f6672a257a1f8 100644 (file)
 #include "h2_h2.h"
 #include "h2_util.h"
 
-#define WRITE_BUFFER_SIZE     (128*1024)
+#define TLS_DATA_MAX          (16*1024) 
+
 /* Calculated like this: assuming MTU 1500 bytes
  * 1500 - 40 (IP) - 20 (TCP) - 40 (TCP options) 
  *      - TLS overhead (60-100) 
  * ~= 1300 bytes */
 #define WRITE_SIZE_INITIAL    1300
-/* Calculated like this: max TLS record size
- * 16*1024
- *      - TLS overhead (60-100) */
-#define WRITE_SIZE_MAX        (16*1024 - 100) 
+/* Calculated like this: max TLS record size 16*1024
+ *   - 40 (IP) - 20 (TCP) - 40 (TCP options) 
+ *    - TLS overhead (60-100) 
+ * which seems to create less TCP packets overall
+ */
+#define WRITE_SIZE_MAX        (TLS_DATA_MAX - 100) 
+
+#define WRITE_BUFFER_SIZE     (8*WRITE_SIZE_MAX)
 
 apr_status_t h2_conn_io_init(h2_conn_io *io, conn_rec *c)
 {
index 0f317ffb3afb9bd2dda66f9f653c11e072915f5b..37cc6a52aa315a24ef324f11efb51808e008c801 100644 (file)
@@ -594,6 +594,20 @@ static int on_send_data_cb(nghttp2_session *ngh2,
     return h2_session_status_from_apr_status(status);
 }
 
+static ssize_t on_data_source_read_length_cb(nghttp2_session *session, 
+                                             uint8_t frame_type, int32_t stream_id, 
+                                             int32_t session_remote_window_size, 
+                                             int32_t stream_remote_window_size, 
+                                             uint32_t remote_max_frame_size, 
+                                             void *user_data)
+{
+    /* DATA frames add 9 bytes header plus 1 byte for padlen and additional 
+     * padlen bytes. Keep below TLS maximum record size.
+     * TODO: respect pad bytes when we have that feature.
+     */
+    return (16*1024 - 10);
+}
+
 #define NGH2_SET_CALLBACK(callbacks, name, fn)\
 nghttp2_session_callbacks_set_##name##_callback(callbacks, fn)
 
@@ -618,6 +632,7 @@ static apr_status_t init_callbacks(conn_rec *c, nghttp2_session_callbacks **pcb)
     NGH2_SET_CALLBACK(*pcb, on_begin_headers, on_begin_headers_cb);
     NGH2_SET_CALLBACK(*pcb, on_header, on_header_cb);
     NGH2_SET_CALLBACK(*pcb, send_data, on_send_data_cb);
+    NGH2_SET_CALLBACK(*pcb, data_source_read_length, on_data_source_read_length_cb);
     
     return APR_SUCCESS;
 }