python-hyper / hpack

HTTP/2 Header Encoding for Python
https://hpack.readthedocs.io/en/latest/
MIT License
72 stars 32 forks source link

Only calculate size of a dynamic table entry once #129

Closed sethmlarson closed 5 years ago

sethmlarson commented 7 years ago

Optimization to reduce the number of calls to table_entry_size by half when adding and evicting entries to the dynamic table so the size of an entry is only calculated on add().

sethmlarson commented 7 years ago

This seems like it would be a breaking change, perhaps this should be bundled up into work to improve the dynamic table lookup speed. Potentially can use a helper object to preserve outward API.

sethmlarson commented 7 years ago

Might write a subclass to deque that handles all shrinking/growing along with preserving public API.

sethmlarson commented 7 years ago

Sure thing, I was about to ask you whether we expect people to mess around with dynamic_entries. I've also got an idea that could bring down our name, value -> index look-up time from O(N) to O(1) while keeping memory usage linear relative to current usage.

I'll have to change a lot of tests that seem to be touching dynamic_entries to make them pass.

sethmlarson commented 7 years ago

My idea to reduce lookup time has too much of a memory usage trade-off. Will take the simple route here, just need to fix some tests.