Skip to content

Initialize media estimates outside the global cache lock - #47856

Merged
copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/079226a58828b854eddc2b501079527bcbe5e603
Sep 24, 2026
Merged

copyberry[bot] merged 1 commit into
mainfrom
copyberry/codex-internal-to-codex-oss/079226a58828b854eddc2b501079527bcbe5e603

Conversation

@copyberry

@copyberry copyberry Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Initialize media estimates outside the global cache lock

Why

Image and audio estimate cache misses computed values while holding the cache mutex, blocking access to unrelated keys during initialization.

What changed

Add BlockingLruCache::get_or_init using Arc> and migrate the image and audio estimate caches to it. Initialization and same-key waits run in a Tokio blocking region after releasing the cache mutex. Callers share initialization while an entry remains cached; eviction can allow another initialization, so factories must be deterministic.

Testing

Add a concurrency test covering access to other keys during initialization, eviction of an in-flight entry, and successful completion of both the evicted initializer and its replacement.

## Why

Image and audio estimate cache misses computed values while holding the cache mutex, blocking access to unrelated keys during initialization.

## What changed

Add `BlockingLruCache::get_or_init` using `Arc>` and migrate the image and audio estimate caches to it. Initialization and same-key waits run in a Tokio blocking region after releasing the cache mutex. Callers share initialization while an entry remains cached; eviction can allow another initialization, so factories must be deterministic.

## Testing

Add a concurrency test covering access to other keys during initialization, eviction of an in-flight entry, and successful completion of both the evicted initializer and its replacement.

GitOrigin-RevId: 079226a58828b854eddc2b501079527bcbe5e603
@copyberry
copyberry Bot force-pushed the copyberry/codex-internal-to-codex-oss/079226a58828b854eddc2b501079527bcbe5e603 branch from 593a1bc to df06bb0 Compare September 24, 2026 14:58
@copyberry
copyberry Bot merged commit df06bb0 into main Sep 24, 2026
@copyberry
copyberry Bot deleted the copyberry/codex-internal-to-codex-oss/079226a58828b854eddc2b501079527bcbe5e603 branch September 24, 2026 14:58
@rafaself
rafaself deployed to issue-triage September 24, 2026 14:58 — with GitHub Actions Active
@rafaself
rafaself deployed to issue-triage September 24, 2026 14:58 — with GitHub Actions Active
@rafaself
rafaself deployed to issue-triage September 24, 2026 14:58 — with GitHub Actions Active
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 24, 2026
@rafaself
rafaself deployed to issue-triage September 24, 2026 14:59 — with GitHub Actions Active

This branch was successfully deployed

1 active deployment
issue-triage — df06bb05 Deployed Sep 24, 2026 by rafaself via Identify potential duplicates (open issues fallback) #48016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants