refactor: generic unbounded cache - #701
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
➖ Are we earthbuild yet?No change in "earthly" occurrences 📈 Overall Progress
Keep up the great work migrating from Earthly to Earthbuild! 🚀 💡 Tips for finding more occurrencesRun locally to see detailed breakdown: ./.github/scripts/count-earthly.shNote that the goal is not to reach 0. |
Signed-off-by: Giles Cope <gilescope@gmail.com>
|
@janishorsts have a look - it seemed there were a few holes (demonstrated by failing tests). I've patched them with claude's help and also switched from using sleeps to something more event based. (I try and avoid sleeps in tests wherever possible) |
Signed-off-by: Giles Cope <gilescope@gmail.com>
|
Feel free to roll back changes you don't like / reimplement! |
@gilescope, nice. I had no idea golang introduced the "testing/synctest" for concurrency testing last year. I always read release notes. Can you please have another look? I did a second round of changes, a significant refactoring. Initially, I was not keen on touching the metacontext package. But as it is used only by the cache implementation, I refactored it to be more idiomatic to Golang concepts. |
…so squished Signed-off-by: Giles Cope <gilescope@gmail.com>
There was a problem hiding this comment.
That's a big diff. Just seemed to be one issue around caching timeouts, please review my commit @janishorsts.
🛠️ Benefits, Issues Resolved & DX Impact
interface{}-based caching with a strongly-typed genericsynccache.Cache[K comparable, V any]implementation featuring zero-allocation cache hits (0 B/op), thread-safe single-flight request coalescing (inflight.go), and clean package scoping ininternal/synccache.buildcontext,cachedmetaresolver,solvecache), and eliminated redundant concurrent load executions for identical in-flight keys.sharedcontext passing. Comprehensive test coverage added for concurrent loads, context cancellations, and race conditions.⚡ Performance Impact
105.4 ns/op52.8 ns/op-49.9%16 B/op0 B/op-100.0%1 allocs/op0 allocs/op-100.0%Note: Benchmarks measured on cache hits using Go 1.26 on darwin/arm64.
📦 Binary Size Impact
31.53 MB/31.60 MB/+64.5 KB(+0.21%)