Skip to content

refactor: generic unbounded cache#701

Open
janishorsts wants to merge 3 commits into
mainfrom
refactor-generic-synccache
Open

refactor: generic unbounded cache#701
janishorsts wants to merge 3 commits into
mainfrom
refactor-generic-synccache

Conversation

@janishorsts

Copy link
Copy Markdown
Collaborator

🛠️ Benefits, Issues Resolved & DX Impact

  • Benefits: Type-safe generic caching (unbounded.Cache[K comparable, V any]), zero-allocation lookup on cache hit, and concurrent value construction coalescing.
  • Issues Eliminated: Refactored legacy non-generic synccache implementation, eliminating heap boxing and runtime interface{} type assertion overhead.
  • Developer Experience (DX) Impact: Fully type-safe cache API with compile-time checking, simplified context propagation, and complete unit test coverage.

⚡ Performance Impact (BenchmarkCache_Do_Hit)

Metric Before (synccache) After (unbounded.Cache) Delta
Execution Time 48.20 ns/op 16.54 ns/op -65.7%
Memory Allocations 16 B/op 0 B/op -100.0%
Heap Mallocs 1 allocs/op 0 allocs/op -100.0%

Benchmark Breakdown

  • BenchmarkCache_Do_Hit: 16.54 ns/op | 0 B/op | 0 allocs/op (Sequential cache hit lookup)
  • BenchmarkCache_Do_ConcurrentHits: 136.40 ns/op | 0 B/op | 0 allocs/op (12-thread parallel cache hits)

📦 Binary Size Impact

  • Stripped Size (Before/After/Delta): 30.23 MB / 30.28 MB / +48.4 KB (+0.16%)

@janishorsts janishorsts self-assigned this Jul 21, 2026
@janishorsts
janishorsts requested a review from a team as a code owner July 21, 2026 20:07
@janishorsts
janishorsts requested review from kmannislands and removed request for a team July 21, 2026 20:07
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

➖ Are we earthbuild yet?

No change in "earthly" occurrences

📈 Overall Progress

Branch Total Count
main 4753
This PR 4753
Difference +0

Keep up the great work migrating from Earthly to Earthbuild! 🚀

💡 Tips for finding more occurrences

Run locally to see detailed breakdown:

./.github/scripts/count-earthly.sh

Note that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.

Signed-off-by: Giles Cope <gilescope@gmail.com>
@gilescope

Copy link
Copy Markdown

@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>
@gilescope

Copy link
Copy Markdown

Feel free to roll back changes you don't like / reimplement!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants