Skip to content

Optimize lookups in large attribute sets - #3

Draft
skrcode wants to merge 1 commit into
mainfrom
jaipilot/optimize-attribute-lookups
Draft

Optimize lookups in large attribute sets#3
skrcode wants to merge 1 commit into
mainfrom
jaipilot/optimize-attribute-lookups

Conversation

@skrcode

Copy link
Copy Markdown
Owner

Summary

  • preserve linear lookup for small attribute sets and the first four entries
  • use binary search over the remaining name-sorted backing array for larger sets
  • keep typed lookup, Value conversion, empty-array fallback, ordering, and missing-key behavior unchanged
  • add focused large-set behavior coverage and a native JMH benchmark

Measured result

The benchmark uses 128 attributes, matching the default span attribute limit. Baseline and candidate ran in the same disposable 4 CPU / 8 GiB workspace with Temurin JDK 21, the same built JMH jar, command, warm-up, and workload. Each row contains 21 observations (7 forks × 3 measured iterations). Lower is better.

LookupBaseline median (ns/op)Candidate median (ns/op)Median reductionBaseline p95Candidate p95p95 reduction
First2.4832.17912.2%2.6372.27213.8%
Middle169.12485.90549.2%178.25088.53750.3%
Last346.19587.32374.8%358.32190.08474.9%
Missing141.56069.55250.9%150.32174.26150.6%
Last as Value368.62972.68480.3%387.46778.08779.8%

The Value workload still allocates about 16 B/op for the returned wrapper; this change improves lookup time rather than claiming that allocation was removed.

Verification

  • the new large-set behavior test passed against the untouched production baseline
  • the identical focused command passed after the production edit
  • local ./gradlew :api:all:check --no-daemon --no-configuration-cache --max-workers=4 passed
  • remote ./gradlew :api:all:clean :api:all:check --no-daemon --no-configuration-cache --no-build-cache --max-workers=4 passed all 147 tasks, including Animal Sniffer, Checkstyle, Spotless, tests, and japicmp
  • the final remote Git delta SHA-256 matched the local candidate exactly

Signed-off-by: Suraj Rajan <surajkrajan95@gmail.com>
Sign up for freeto 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.

1 participant

@skrcode