Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5562 Improve HTTP Field cache allocation #5565

Merged
merged 9 commits into from Nov 12, 2020

Conversation

gregw
Copy link
Contributor

@gregw gregw commented Nov 3, 2020

Fix #5562 by initially putting cacheable fields into a inexpensive arraylist.
Only create the Trie (with space and complexity costs) if a second request is received.

Edit: the original PR only created the Trie on the second request, but that behaviour was removed in reviews. The cache is now created every request, even for non persistent requests.

Fix #5562 by initially putting cacheable fields into a inexpensive arraylist.
Only create the Trie (with space and complexity costs) if a second request is received.
@gregw gregw requested review from sbordet and lorban November 3, 2020 13:29
@gregw gregw linked an issue Nov 3, 2020 that may be closed by this pull request
Copy link
Contributor

@sbordet sbordet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly fond of this change.

I am positive on delaying the creation of the Trie, until we know it's a HTTP/1.1 and we do have cache size > 0.

Seems to me that the chances for caching are the most common case by far, so I would skip the temporary list and go straight to the trie.

Create `HttpHeader.isPseudo()`` method
improved clarity with `createFieldCacheIfNeeded()``
@sbordet
Copy link
Contributor

sbordet commented Nov 4, 2020

@gregw also, I think we need some test -- something that verifies that the field is == in subsequent requests, etc.

@gregw
Copy link
Contributor Author

gregw commented Nov 4, 2020

@sbordet There are cache tests and they were broken until I fixed getFieldCache() to create the cache if needed. I think that method only really exists for the tests.

Only defer Trie creation to first cacheable field, not until next request.
@gregw gregw requested a review from sbordet November 4, 2020 10:30
@gregw
Copy link
Contributor Author

gregw commented Nov 4, 2020

@lorban see the emptyTrie method I've added here. Also I wonder why the HttpField cache uses the Terniary Trie rather than just the array Trie.

I think this is one of the most important (if not THE important) case to optimise Tries for. We basically have the static and dynamic Tries... it is almost like HTTP/2 Hpack.
I wonder if we'd be better off with a specific cache class rather than generic Tries ?

@gregw gregw requested a review from sbordet November 5, 2020 10:15
@gregw gregw requested a review from lorban November 11, 2020 17:36
@gregw
Copy link
Contributor Author

gregw commented Nov 12, 2020

@lorban nudge

@gregw gregw merged commit f4c32e7 into jetty-9.4.x Nov 12, 2020
@gregw gregw deleted the jetty-9.4.x-5562-improve-field-cache branch November 12, 2020 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArrayTernaryTrie consumes too much memory
3 participants