Repository navigation
Use PrefixedIncrementingId for BasicHttpClientConnectionManager id - #913
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BasicHttpClientConnectionManagerstill builds its id withString.format("ep-%010d", ...). #352 replaced the same pattern withPrefixedIncrementingIdinExecSupportand in both pooling connection managers, but this one was left out. This switches it toPrefixedIncrementingId("ep-")as well, so all three connection managers generate ids the same way. The format staysep-followed by 10 digits.Benchmark
JMH,
-prof gc, 2 forks x 5 iterations, Apple M4 Pro. Benchmark source:String.format("ep-%010d", counter.getAndIncrement())vsPrefixedIncrementingId.getNextId().Time per id (ns/op, lower is better)
String.formatPrefixedIncrementingIdxychart-beta title "ns/op (bar: String.format, line: PrefixedIncrementingId)" x-axis ["JDK 8", "JDK 11", "JDK 17", "JDK 21", "JDK 25"] y-axis "ns/op" 0 --> 350 bar [327.1, 256.0, 307.6, 230.6, 97.9] line [16.9, 13.5, 12.9, 12.0, 11.2]Allocation per id (B/op, lower is better)
String.formatPrefixedIncrementingIdxychart-beta title "B/op (bar: String.format, line: PrefixedIncrementingId)" x-axis ["JDK 8", "JDK 11", "JDK 17", "JDK 21", "JDK 25"] y-axis "B/op" 0 --> 1500 bar [1304, 724, 1416, 656, 498] line [136, 88, 88, 88, 88]JDK 8 was measured with JMH 1.36, since the 1.37 GC profiler reports 0 B/op there. The other JDKs use 1.37.
The id is created once per manager instance, so this only really shows up when a client is created per request. It's mostly a consistency fix.
Notes
ep-0000000001instead ofep-0000000000, the same as the pooling managers. The id is only used in log output.PrefixedIncrementingIdis backed by anAtomicLong, so uniqueness under concurrent construction is unchanged.mvn -pl httpclient5 verifypasses (1113 tests, checkstyle, japicmp).