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

Speedup HTTP headers lowercase transformation #5055

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

franz1981
Copy link
Contributor

@franz1981 franz1981 commented Jan 9, 2024

In some simple HTTP 2 hello world benchmarks, HttpUtils::toLowerCase has pop-up due to how Quarkus handle HTTP headers using Jax-RS HTTP header name constants ie using capital letters in Strings eg "Content-Type".

image

This is speeding up the String lowercase transformation case improving the others, where possible.

baseline:

Benchmark                                       (lowerCase)   (type)  Mode  Cnt   Score   Error  Units
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false    ascii  avgt   20  29.698 ± 0.195  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false   string  avgt   20  23.967 ± 0.791  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false  builder  avgt   20  24.155 ± 0.905  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true    ascii  avgt   20   6.625 ± 0.008  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true   string  avgt   20   4.932 ± 0.015  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true  builder  avgt   20   5.654 ± 0.021  ns/op

b2925a8 :

Benchmark                                       (lowerCase)   (type)  Mode  Cnt   Score   Error  Units
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false    ascii  avgt   20  10.988 ± 0.258  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false   string  avgt   20  13.255 ± 0.111  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase        false  builder  avgt   20  24.846 ± 1.290  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true    ascii  avgt   20   6.107 ± 0.007  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true   string  avgt   20   5.078 ± 0.053  ns/op
HttpUtilsAsciiToLowerCaseBenchmark.toLowerCase         true  builder  avgt   20   5.619 ± 0.017  ns/op

This change is kind-of related to https://github.com/quarkusio/quarkus/pull/37619/files#diff-7cd9e11ea75ab750663bd15870c0749df275c32fd3d8eb2dfdc8eb706e4db540L499
which, instead, try to address it by forcing to use the same AsciiString of vertx, but introducing some ugly APIs which doesn't fit with the rest.

That's why I think that improving on Vertx side is more beneficial for this

@vietj vietj merged commit 4e5c0cd into eclipse-vertx:4.x Jan 9, 2024
6 checks passed
@vietj vietj added this to the 4.5.2 milestone Jan 9, 2024
@franz1981 franz1981 deleted the 4.x_opt_tolower branch January 11, 2024 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants