• Tom Bergan's avatar
    http2/hpack: speedup Encoder.searchTable · bce15e71
    Tom Bergan authored
    The previous algorithm was linear in the size of the table.
    The new algorithm is O(1). The new algorithm should behave exactly
    like the old algorthm, except for one unimportant change that
    triggered small updates to tests in encode_test.go:
    
    When encoding "Field: Value" where the table has two entries,
    [0]={"Field", "X"} and [1]={"Field", "Y"}, we can encode the field
    name using either table entry. Previously, we selected the oldest
    entry, but now we select the newest entry. The new implementation
    should actually generate very slightly better compression because
    new entries are encoded with smaller integers than old entries, and
    HPACK uses a varint encoding for integers where smaller integers
    are encoded in fewer bytes.
    
    I added a synthetic microbenchmark which shows a big speedup in
    hpack.Encoder.searchTable:
    
    BenchmarkEncoderSearchTable-40  100000 127440 ns/op  # before
    BenchmarkEncoderSearchTable-40   50000  25121 ns/op  # after
    
    Change-Id: Ib87d61b6415d9f0ff38874fe2a719b2f00351590
    Reviewed-on: https://go-review.googlesource.com/37406Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    bce15e71
Name
Last commit
Last update
bpf Loading commit data...
context Loading commit data...
dict Loading commit data...
html Loading commit data...
http2 Loading commit data...
icmp Loading commit data...
idna Loading commit data...
internal Loading commit data...
ipv4 Loading commit data...
ipv6 Loading commit data...
lex/httplex Loading commit data...
lif Loading commit data...
nettest Loading commit data...
netutil Loading commit data...
proxy Loading commit data...
publicsuffix Loading commit data...
route Loading commit data...
trace Loading commit data...
webdav Loading commit data...
websocket Loading commit data...
xsrftoken Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
codereview.cfg Loading commit data...