Skip to content

Add short-TTL attribute cache for serveBlobInfo#193

Merged
raymondjacobson merged 3 commits intoOpenAudio:mainfrom
RolfAris:feat/serveblobinfo-attr-cache
Apr 4, 2026
Merged

Add short-TTL attribute cache for serveBlobInfo#193
raymondjacobson merged 3 commits intoOpenAudio:mainfrom
RolfAris:feat/serveblobinfo-attr-cache

Conversation

@RolfAris
Copy link
Copy Markdown
Contributor

@RolfAris RolfAris commented Apr 1, 2026

Summary

  • Cache bucket.Attributes results in serveBlobInfo for 60s to reduce HeadObject calls from peer probes. 50K entries, LRU eviction, per-entry TTL. No negative caching.
  • Move the dbHealthy check before the storage call so unhealthy nodes return 500 without hitting R2.

Cache bucket.Attributes results in serveBlobInfo for 60s to reduce
HeadObject calls from peer probes. Peers re-verify redirect targets
on every request, and sniffAndFix fans out to all nodes per CID,
making this endpoint a significant source of metadata API calls.

Also moves the dbHealthy check before the storage call so unhealthy
nodes return 500 without hitting the storage backend.
Comment thread pkg/mediorum/server/server.go Outdated
uploadOrigCidCache: imcache.New(imcache.WithMaxEntriesLimitOption[string, string](50_000, imcache.EvictionPolicyLRU)),
imageCache: imcache.New(imcache.WithMaxEntriesLimitOption[string, []byte](10_000, imcache.EvictionPolicyLRU)),
trackAccessInfoCache: imcache.New(imcache.WithMaxEntriesLimitOption[string, trackAccessInfo](50_000, imcache.EvictionPolicyLRU), imcache.WithDefaultExpirationOption[string, trackAccessInfo](5*time.Minute)),
attrCache: imcache.New(imcache.WithMaxEntriesLimitOption[string, *blob.Attributes](50_000, imcache.EvictionPolicyLRU)),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

50K is huge for this if it has 60s expiry - this would be > 800 unique CID per second to fill, updating to 10K & then will merge

With a 60s TTL, 50K entries is oversized — 10K is plenty for the
expected lookup rate and avoids unnecessary memory reservation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raymondjacobson raymondjacobson merged commit 81e7014 into OpenAudio:main Apr 4, 2026
2 of 6 checks passed
@RolfAris RolfAris deleted the feat/serveblobinfo-attr-cache branch May 2, 2026 13:37
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