Files
codex/codex-rs/utils
Charlie Marsh f64f003d98 Release unchanged prompt image buffers when callers drop them (#63563)
## Why

The prompt image cache keeps original image bytes in memory after the
last caller releases them. A later request already supplies those bytes,
so the cache only needs to remember that they decoded successfully and
could be used as-is.

## What changed

Cache the format and dimensions of validated, unchanged images with a
weak reference to the source buffer. Matching requests share the buffer
while it is live. After it is released, a cache hit takes ownership of
the new input buffer without copying or decoding it again. Concurrent
misses reuse the first live result when inserting into the cache.

Key entries by a BLAKE3 hash of the input, image mode, and decoder
choice. Keep transformed outputs in the cache and apply the byte budget
using source length for unchanged images and allocation capacity for
transformed outputs.

## Testing

Cover buffer sharing and release, reuse after release, concurrent cache
misses, and byte-budget eviction. Verify that a warm cache still rejects
a PNG with corrupt pixel data.

GitOrigin-RevId: b830ecaf8af713bdcc4d1c7782675ad77db74229
2026-11-24 06:52:29 +00:00
..
…