Skip to content

replacer: cache file lookups and cap them - #8248

Merged
mohammed90 merged 5 commits into
masterfrom
cap-file-replacements
Oct 24, 2026
Merged

mohammed90 merged 5 commits into
masterfrom
cap-file-replacements

Conversation

@mohammed90

Copy link
Copy Markdown
Member

OSS-Fuzz reports timeout (> 60 seconds) on large number of {file. replacements. The culprit in oss-fuzz sample is repetitive replacements of the same referenced file. Now the replacement of unique file is cached. Moreover, a reasonable cap of 1000 is introduced to avoid recurrence with huge number of unique files.

1000 file replacements ought to be enough for anybody

Fixes #8247

Assistance Disclosure

(Copilot/Sonnet 5) generated the code, and I verified it is correct.

Comment thread replacer.go Resolved

@kimjooyoon kimjooyoon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex agent review. One reproduced cache-recognition regression is attached inline; no overall approval or full-suite claim.

Comment thread replacer.go Resolved
Memoize file placeholder results per replacement call, using an 8 MiB LRU for contents. Preserve empty and failed-read results without changing the output for unknown placeholders.

Signed-off-by: Mohammed Al Sahaf <[email protected]>
Comment thread replacer.go Resolved
@mohammed90
mohammed90 enabled auto-merge (squash) October 24, 2026 22:10
@mohammed90 mohammed90 added bug 🐞 Something isn't working optimization 📉 Performance or cost improvements and removed bug 🐞 Something isn't working labels Oct 24, 2026
@mohammed90 mohammed90 added this to the v2.12.0 milestone Oct 24, 2026
@mohammed90
mohammed90 merged commit 4e8de21 into master Oct 24, 2026
29 checks passed
@mohammed90
mohammed90 deleted the cap-file-replacements branch October 24, 2026 22:32
This was referenced Nov 3, 2026
NickCao pushed a commit to NickCao/caddy that referenced this pull request Nov 4, 2026
* replacer: cache file lookups and cap them

Signed-off-by: Mohammed Al Sahaf <[email protected]>

* replacer: cache repeated file placeholder lookups

Memoize file placeholder results per replacement call, using an 8 MiB LRU for contents. Preserve empty and failed-read results without changing the output for unknown placeholders.

Signed-off-by: Mohammed Al Sahaf <[email protected]>

---------

Signed-off-by: Mohammed Al Sahaf <[email protected]>
(cherry picked from commit 4e8de21)
@francislavoie francislavoie modified the milestones: v2.12.0, v2.11.8 Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization 📉 Performance or cost improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fuzz-replacer: Timeout in fuzz-replacer

4 participants