Skip to content

feat: [cache/memory] use ristretto as memory backend#917

Merged
crandles merged 6 commits intotrickstercache:mainfrom
crandles:memory-v2
Feb 19, 2026
Merged

feat: [cache/memory] use ristretto as memory backend#917
crandles merged 6 commits intotrickstercache:mainfrom
crandles:memory-v2

Conversation

@crandles
Copy link
Contributor

@crandles crandles commented Feb 17, 2026

Replaced the memory cache's sync.Map usage with ristretto, which has its own cost / TTL based eviction mechanism. This should be more performant than a sync.Map for concurrent read/write usage.

This allows us to skip our index client wrapper as well, for the memory provider.

Note: ristretto is utilized by the BadgerDB cache that we have an existing integration with.


I would say the memory profile appears to have improved -- running make serve-dev with example dashboards auto-refreshing:

sum(process_resident_memory_bytes{job="trickster"}) by (instance)
sum by (instance) (go_memstats_sys_bytes{job="trickster"})
sum by (instance) (go_memstats_alloc_bytes{job="trickster"})

main vs current branch
Screenshot 2026-02-19 at 5 16 39 PM

Signed-off-by: Chris Randles <randles.chris@gmail.com>
Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles changed the title feat: [caches/memory] use ristretto as memory backend feat: [cache/memory] use ristretto as memory backend Feb 17, 2026
@coveralls
Copy link

coveralls commented Feb 17, 2026

Pull Request Test Coverage Report for Build 22082628985

Details

  • 42 of 55 (76.36%) changed or added relevant lines in 5 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 72.064%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/cache/providers/providers.go 0 1 0.0%
pkg/frontend/options/options.go 1 3 33.33%
pkg/observability/tracing/options/options.go 1 3 33.33%
pkg/cache/memory/memory.go 39 47 82.98%
Files with Coverage Reduction New Missed Lines %
pkg/cache/options/options.go 1 55.29%
pkg/proxy/engines/cache_read.go 2 81.82%
Totals Coverage Status
Change from base Build 22071487246: 0.01%
Covered Lines: 14887
Relevant Lines: 20658

💛 - Coveralls

Signed-off-by: Chris Randles <randles.chris@gmail.com>
Signed-off-by: Chris Randles <randles.chris@gmail.com>
Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles marked this pull request as ready for review February 19, 2026 22:22
@crandles crandles requested a review from a team as a code owner February 19, 2026 22:22
Signed-off-by: Chris Randles <randles.chris@gmail.com>
@crandles crandles merged commit 0c64902 into trickstercache:main Feb 19, 2026
7 checks passed
@crandles crandles deleted the memory-v2 branch February 19, 2026 22:39
@crandles crandles mentioned this pull request Feb 19, 2026
2 tasks
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.

3 participants