mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
## 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
36 lines
1020 B
TOML
36 lines
1020 B
TOML
[package]
|
|
name = "codex-utils-image"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
license.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.cargo-shear]
|
|
# "image" does not forward png's zlib-rs feature. This direct dependency keeps
|
|
# encoded PNG bytes stable when WebSocket dependencies are absent from a build.
|
|
ignored = ["png"]
|
|
|
|
[dependencies]
|
|
base64 = { workspace = true }
|
|
blake3 = { workspace = true }
|
|
image = { version = "=0.25.9", default-features = false, features = ["jpeg", "png", "gif", "webp"] }
|
|
moxcms = { version = "=0.7.11", features = ["options"] }
|
|
png = { version = "=0.18.1", features = ["zlib-rs"] }
|
|
codex-utils-cache = { workspace = true }
|
|
mime_guess = { workspace = true }
|
|
thiserror = { workspace = true }
|
|
tokio = { workspace = true, features = ["fs", "rt", "rt-multi-thread", "macros"] }
|
|
|
|
[dev-dependencies]
|
|
divan = { workspace = true }
|
|
image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] }
|
|
|
|
[lib]
|
|
doctest = false
|
|
|
|
[[bench]]
|
|
name = "prompt_images"
|
|
harness = false
|