Skip to content

bound prompt image cache retention#28294

Merged
jif-oai merged 3 commits into
mainfrom
codex/optimize-prompt-image-cache
Jun 15, 2026
Merged

bound prompt image cache retention#28294
jif-oai merged 3 commits into
mainfrom
codex/optimize-prompt-image-cache

Conversation

@jif-oai

@jif-oai jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Why

The prompt image cache was bounded to 32 entries, but not by the size of those entries. A set of large encoded images could therefore retain substantially more memory than intended. Cache hits also cloned the full encoded payload.

What changed

  • cap the cache at 64 MiB of encoded image data while preserving its existing 32-entry limit
  • skip caching an image that exceeds the entire byte budget
  • evict least-recently-used entries until the cache is back within its byte budget
  • share cached encoded bytes with Arc<[u8]> so cache hits do not deep-clone image payloads

Validation

  • just test -p codex-utils-image

@jif-oai jif-oai marked this pull request as ready for review June 15, 2026 13:13
@jif-oai jif-oai changed the title [codex] optimize prompt image processing and cache retention optimize prompt image processing and cache retention Jun 15, 2026
@jif-oai jif-oai changed the title optimize prompt image processing and cache retention bound prompt image cache retention Jun 15, 2026
@jif-oai

jif-oai commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 0eeef9d02a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jif-oai jif-oai merged commit aae4c0b into main Jun 15, 2026
30 of 31 checks passed
@jif-oai jif-oai deleted the codex/optimize-prompt-image-cache branch June 15, 2026 17:52
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 15, 2026
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