Incremental indexing only when the entry size if less than threshold

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-27 20:48:04 +09:00
parent f74674aa7f
commit 7021a9fc5e
2 changed files with 43 additions and 20 deletions

View File

@ -812,34 +812,56 @@ ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_context *deflater,
/* Check name exists in hd_table */ /* Check name exists in hd_table */
ent = find_name_in_hd_table(deflater, &nv[i]); ent = find_name_in_hd_table(deflater, &nv[i]);
if(ent) { if(ent) {
nghttp2_hd_entry *new_ent;
uint8_t index = ent->index; uint8_t index = ent->index;
new_ent = add_hd_table_incremental(deflater, &nv[i]); int incidx = 0;
if(!new_ent) { if(entry_room(nv[i].namelen, nv[i].valuelen)
rv = NGHTTP2_ERR_HEADER_COMP; < NGHTTP2_HD_MAX_ENTRY_SIZE) {
goto fail; nghttp2_hd_entry *new_ent;
} new_ent = add_hd_table_incremental(deflater, &nv[i]);
rv = add_workingset(deflater, new_ent); if(!new_ent) {
if(rv < 0) { rv = NGHTTP2_ERR_HEADER_COMP;
goto fail; goto fail;
}
rv = add_workingset(deflater, new_ent);
if(rv < 0) {
goto fail;
}
incidx = 1;
} else {
rv = add_workingset_indname(deflater, ent, nv[i].value,
nv[i].valuelen);
if(rv < 0) {
goto fail;
}
} }
rv = emit_indname_block(buf_ptr, buflen_ptr, &offset, index, rv = emit_indname_block(buf_ptr, buflen_ptr, &offset, index,
nv[i].value, nv[i].valuelen, 1); nv[i].value, nv[i].valuelen, incidx);
if(rv < 0) { if(rv < 0) {
goto fail; goto fail;
} }
} else { } else {
nghttp2_hd_entry *new_ent; int incidx = 0;
new_ent = add_hd_table_incremental(deflater, &nv[i]); if(entry_room(nv[i].namelen, nv[i].valuelen)
if(!new_ent) { < NGHTTP2_HD_MAX_ENTRY_SIZE) {
rv = NGHTTP2_ERR_HEADER_COMP; nghttp2_hd_entry *new_ent;
goto fail; new_ent = add_hd_table_incremental(deflater, &nv[i]);
if(!new_ent) {
rv = NGHTTP2_ERR_HEADER_COMP;
goto fail;
}
rv = add_workingset(deflater, new_ent);
if(rv < 0) {
goto fail;
}
incidx = 1;
} else {
rv = add_workingset_newname(deflater, &nv[i]);
if(rv < 0) {
goto fail;
}
} }
rv = add_workingset(deflater, new_ent); rv = emit_newname_block(buf_ptr, buflen_ptr, &offset, &nv[i],
if(rv < 0) { incidx);
goto fail;
}
rv = emit_newname_block(buf_ptr, buflen_ptr, &offset, &nv[i], 1);
if(rv < 0) { if(rv < 0) {
goto fail; goto fail;
} }

View File

@ -36,6 +36,7 @@
#define NGHTTP2_INITIAL_WS_SIZE 128 #define NGHTTP2_INITIAL_WS_SIZE 128
#define NGHTTP2_HD_MAX_BUFFER_SIZE 4096 #define NGHTTP2_HD_MAX_BUFFER_SIZE 4096
#define NGHTTP2_HD_MAX_ENTRY_SIZE 1024
#define NGHTTP2_HD_ENTRY_OVERHEAD 32 #define NGHTTP2_HD_ENTRY_OVERHEAD 32
/* This value is sensible to NGHTTP2_HD_MAX_BUFFER_SIZE. Currently, /* This value is sensible to NGHTTP2_HD_MAX_BUFFER_SIZE. Currently,