Repository navigation
perf: avoid formatter allocations in YCSB hash keys - #285
Open
perfloop[bot] wants to merge 1 commit into
Open
perfloop[bot] wants to merge 1 commit into
perfloop[bot] wants to merge 1 commit into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai>
|
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.
hashKeyruns before YCSB worker operations and while preloading keys. It keeps the eight-byte FNV-1a sweep and replacesfmt.Sprintfwith a 20-byte stack buffer andstrconv.AppendUint. The returned key staysuser-prefixed, lowercase, and unpadded. The formatter-equivalence test covers zero, positive, negative, and signedintboundaries.The direct hash benchmark reports per-call time and bytes. A fixed 100,000-call batch gates at least 100,000 fewer allocation events, one for each hash call. A separate
RunYCSBWithContextworkload runs 100,000 read-only operations with eight workers, 1,000 keys, and 100-byte values against an in-memory loopback gRPC server. Its full-run allocation result is a sampled Goalloc_spaceestimate attributed tohashKey, including preload; it is not total process allocation or production traffic. Worker-time and throughput are guards, not speedup claims;Result.Durationincludes worker hashes but excludes preload and final reporting. The direct-hash and large-run profile harnesses are retained measurement support and are not included in this PR.On workload
YCSB hashKey for 100,000 nonnegative key numbers per sample, median metrichashkey_allocs_per_100000_callschanged from 200009 to 100000; paired median delta -100008 (-50% of baseline; at least 19/20 confidence interval -100010 to -100007 from 10 pairs).ns/opB/ophashkey_allocs_per_100000_callshashkey_alloc_bytes_per_ycsb_runEach workload ran 10 paired runs.
The existing
BenchmarkRunYCSBReadOnly/64KiBis an additional allocation guard; each Go benchmark iteration is one 64-operation read-onlyRunYCSBWithContextinvocation with four workers, one key, and 64KiB values. Three one-second diagnostic samples reportedallocs/opof 24,902 / 24,805 / 24,818 before the change and 24,747 / 24,757 / 24,809 after it. These diagnostic runs are separate from the official paired claim results. No new benchmark or build target is added to the PR.YCSB Workload C, 64 operations, 4 workers, 1 key, 64KiB values, loopback gRPC(10 paired runs): declared guards passed.make test-client,make build-cli,make fmt-check,make license-check, and clientgo vet ./...pass. The full repositorymake lintremains for target CI.Generated by Perfloop.
Note
Low Risk
Behavior-preserving hot-path optimization with an equivalence test; key format and hashing logic are unchanged.
Overview
Optimizes YCSB
hashKeyso preload and every worker op spend less time and heap on key strings. The FNV-1a hash is unchanged; only string assembly moves fromfmt.Sprintf("user%x", h)to a fixeduserprefix on a 20-byte stack buffer plusstrconv.AppendUint(lowercase, unpadded hex).Adds
TestHashKeyMatchesFormatter, which compares the new path to the old formatter for zero, typical values, and signedintmin/max so key names stay compatible with existing caches and tests.Reviewed by Cursor Bugbot for commit 133bd25. Bugbot is set up for automated code reviews on this repo. Configure here.