Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: adac971eb4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
|
||
| results := make([]rootDomainProbeResult, len(unique)) | ||
| arena := newGetManyValueCopyArena(len(keys)) | ||
| arena := newGetManyValueCopyArena(len(unique)) |
There was a problem hiding this comment.
Size the arena by copied result count
For duplicate-heavy GetMany calls with non-trivial values, len(unique) can be 1 while copyToRefs still appends the value once for every duplicate ref in groupRefs. Starting the arena at unique * 128 therefore forces repeated reallocations, and the returned slices from earlier appends keep those old backing arrays alive, so a call like hundreds of duplicate probes for a 128B+ value can retain extra copied buffers and lose the allocation benefit this path is meant to provide. The allocation hint needs to reflect the number of output copies, not only the number of lookup probes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR refines the GetMany fast-path for published-root point shards by sizing the value-copy arena based on the number of unique probes rather than the total number of requested keys, reducing unnecessary preallocation when the request contains many duplicate keys.
Changes:
- Allocate the published-root
GetManycopy arena usinglen(unique)instead oflen(keys)to avoid duplicate-driven overallocation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
GetManycopy arena from the number of unique probes instead of total requested keys.Validation
go test ./TreeDB/caching -count=1go test ./TreeDB/caching -run ^ -bench ^BenchmarkGetMany_PublishedRootPointShards -benchmem -benchtime=300ms -count=5 -p=1Benchmark evidence vs current
origin/main(d55deb8ae5):