Add an interactive Hashtable internals demo - #12334
Draft
bric3 wants to merge 1 commit into
Draft
Conversation
This comment has been minimized.
This comment has been minimized.
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
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.
What Does This Do
Adds a standalone animated demo for
datadog.trace.util.Hashtable. Each step keeps the abridged Java code, bucket array, linked entry chains, hash masking, and iterator state synchronized.The demo contains five sections with a suggested scenario for each:
D1)getthrough the linked chain, then mutate the returned entry in place.D2)getOrCreateandforEach)CardinalityLimitReporterfrom a miss through creator invocation and insertion, reuse the entry on a hit, summarize with a context-passing consumer, then clear the table.insertOrReplaceandremove)MutatingBucketIterator, expose its predecessor/current/next references in a separate band, replace a middle entry, then unlink the tail in constant time.Hashtable.Support)AggregateTableacross reporting cycles, leave one aggregate stale, miss on a new key at the logical cap, evict through a cursor-resumed sweep, then admit the new aggregate.A final API map compares when to use
D1,D2, orSupportand summarizes their contracts.Motivation
Hashtableis deliberately smaller and more specialized thanHashMap, but several important mechanics are easy to miss during code review: an array slot points to a linked entry chain, bucket masking does not establish key identity,getOrCreateinvokes its creator only after a miss, mutating iterators retain splice pointers, and custom callers own capacity and eviction policy.The demo makes those relationships visible and gives reviewers concrete scenarios for the main APIs and their production usage.
Additional Notes
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueJira ticket: N/A