Skip to content

Optimize InternalNames lookup - #143

Open
mcculls wants to merge 1 commit into
mainfrom
mcculls/internal-names-collisions
Open

mcculls wants to merge 1 commit into
mainfrom
mcculls/internal-names-collisions

Conversation

@mcculls

@mcculls mcculls commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Does This Do

Replace bounded rehashing and repeated table growth in InternalNames with a fixed table sized to at most 50% load. Resolve collisions with linear probing and cache hashes in a parallel array so lookups skip strings whose hashes differ. Names are normalized and deduplicated during construction, and lookups continue to support allocation-free queries using String or any CharSequence with a String-compatible hash code.

Motivation

Distinct names with identical String hashes follow the same probe sequence. Repeatedly growing the table cannot resolve those collisions and can exhaust the heap. Linear probing handles these collisions without rebuilding or growing the table.

Additional Notes

  • Add regression coverage for identical hashes, probe runs and wraparound, normalized duplicates, missing names, allocation-free CharSequence queries, matcher factory integration, and set behavior.
  • Move the shared class-name corpus into testing, expose it through SampleClasses.loadClassNames(), and update the utils benchmarks to use it.
  • Add an InternalNames benchmark that checks all 33,957 corpus names against 25 groups sampled from dd-trace-java with both String and TypeString queries. It reports time per corpus class across all groups, normalizes names and precomputes query hashes outside measurement, validates membership against HashSet during setup, and returns the total match count to keep all lookups observable.

Contributor Checklist

  • class-match tests passed on JDK 8, 11, 17, 21, and 25.
  • class-match formatting checks passed.

@mcculls
mcculls marked this pull request as ready for review October 17, 2026 18:38
@mcculls
mcculls requested a review from a team as a code owner October 17, 2026 18:38
@mcculls
mcculls requested review from jordan-wong and removed request for a team October 17, 2026 18:38
@mcculls
mcculls force-pushed the mcculls/internal-names-collisions branch 10 times, most recently from 534d5d2 to 110868d Compare October 18, 2026 16:09
@datadog-datadog-prod-us1

This comment has been minimized.

@mcculls
mcculls force-pushed the mcculls/internal-names-collisions branch 3 times, most recently from 532c53d to 9869a4e Compare October 18, 2026 18:21
Replaces bounded rehashing and repeated table growth with a fixed table
sized to at most 50% load. Resolves collisions by linear probing and keeps
hashes in a parallel array to avoid accessing strings whose hashes differ.

Collisions, wraparound, normalized duplicates, and allocation-free
CharSequence lookups are checked in InternalNamesTest.

Moves the class-name corpus into testing and exposes it through
SampleClasses.loadClassNames(). Updates the utils benchmarks to use the
shared resource, and adds an InternalNames benchmark matching all 33,957
corpus names against 25 groups sampled from dd-trace-java, using both
String and TypeString queries.

The benchmark checks every corpus class against every sampled group and
reports time per class. It normalizes names and precompute hashes outside
measurement, validates membership against HashSet during setup, and returns
the total match count to keep all lookups observable.
@mcculls
mcculls force-pushed the mcculls/internal-names-collisions branch from 9869a4e to b9370e6 Compare October 18, 2026 18:28
@mcculls mcculls changed the title Bound InternalNames hash-table growth Optimize InternalNames lookup Oct 18, 2026

This branch has not been deployed

No deployments
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.

1 participant