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

Cache parsing of content-type header #3011

Merged
merged 4 commits into from
Aug 12, 2024

Conversation

kyri-petrou
Copy link
Collaborator

#2969 unknowingly introduced a ~10% regression in performance for simple requests when the content-type header is present. This regression was introduced because parsing of the content-type header is a fairly expensive (~1us to parse application/json based on some basic benchmarking), and to make things worse, it is executed within Netty's event loop which should not be performing CPU-intensive work.

On one hand, we could simply revert the PR or parse the content-type header only when needed, but I doubt this is the first time someone will accidentally do this. In order to guard against such usages in the future, this PR adds a cache infront of the content-type header parser. Since this can be potentially, we guard against this by clearing the cache if it grows too big. This size (8192 entries) should never be reached for standard usages

@kyri-petrou kyri-petrou requested a review from 987Nabil August 12, 2024 12:58
@987Nabil 987Nabil merged commit acd6445 into zio:main Aug 12, 2024
34 checks passed
@kyri-petrou kyri-petrou deleted the cache-parsed-content-type branch August 12, 2024 15:40
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.

2 participants