Skip to content

Use PrefixedIncrementingId for BasicHttpClientConnectionManager id - #913

Merged
ok2c merged 1 commit into
apache:masterfrom
shinseongsu:basic-conn-manager-id
Oct 30, 2026
Merged

ok2c merged 1 commit into
apache:masterfrom
shinseongsu:basic-conn-manager-id

Conversation

@shinseongsu

@shinseongsu shinseongsu commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

BasicHttpClientConnectionManager still builds its id with String.format("ep-%010d", ...). #352 replaced the same pattern with PrefixedIncrementingId in ExecSupport and in both pooling connection managers, but this one was left out. This switches it to PrefixedIncrementingId("ep-") as well, so all three connection managers generate ids the same way. The format stays ep- followed by 10 digits.

Benchmark

JMH, -prof gc, 2 forks x 5 iterations, Apple M4 Pro. Benchmark source: String.format("ep-%010d", counter.getAndIncrement()) vs PrefixedIncrementingId.getNextId().

Time per id (ns/op, lower is better)

JDK String.format PrefixedIncrementingId Speedup
8u512 327.1 ± 5.4 16.9 ± 0.3 19.4x
11.0.28 256.0 ± 18.4 13.5 ± 1.1 18.9x
17.0.16 307.6 ± 3.6 12.9 ± 0.5 23.9x
21.0.10 230.6 ± 3.3 12.0 ± 0.3 19.2x
25.0.1 97.9 ± 11.3 11.2 ± 0.3 8.7x
xychart-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]
Loading

Allocation per id (B/op, lower is better)

JDK String.format PrefixedIncrementingId Reduction
8u512 1304 136 9.6x
11.0.28 724 88 8.2x
17.0.16 1416 88 16.1x
21.0.10 656 88 7.5x
25.0.1 498 88 5.7x
xychart-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]
Loading

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

  • Ids now start at ep-0000000001 instead of ep-0000000000, the same as the pooling managers. The id is only used in log output.
  • PrefixedIncrementingId is backed by an AtomicLong, so uniqueness under concurrent construction is unchanged.
  • mvn -pl httpclient5 verify passes (1113 tests, checkstyle, japicmp).

@ok2c
ok2c merged commit fbddce4 into apache:master Oct 30, 2026
9 checks passed
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