Conversation
- Replaced concurrent `Range` iteration with sequential shard iteration. - Removed `sync.Mutex` and goroutine overhead. - Maintained expiration logic for invalid items. - Benchmarks show ~3.5x latency improvement and ~30x fewer allocations.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR improves gache.(*gache).ToRawMap performance by removing the per-entry mutex + concurrent shard Range pattern (which caused lock contention) and instead iterating shards sequentially and writing to the output map directly.
Changes:
- Replaced
ToRawMap’sg.Range(...)(concurrent shard iteration) with a sequential loop overg.shards. - Removed the mutex previously required to protect concurrent writes to the output map.
- Preserved existing behavior of omitting expired entries and triggering expiration cleanup during traversal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This PR optimizes
ToRawMapby replacing the concurrentg.Rangecall (which caused high lock contention on a single mutex) with a sequential iteration over the shards. SinceToRawMapconstructs a new map, sequential writes are safe and significantly faster than managing 512 concurrent goroutines fighting for a single lock.Performance Impact:
Tests passed.
PR created automatically by Jules for task 9827599965449859755 started by @kpango