perf(citation): optimize CITATION.cff rendering - #39575
Open
silverwind wants to merge 2 commits into
Open
silverwind wants to merge 2 commits into
silverwind wants to merge 2 commits into
Conversation
Rendering a CITATION.cff could use memory far out of proportion to the file, as every YAML alias copies its target into the formatted citation and the parser copies %TAG prefixes into every node. Skip files over 256 KiB, files with %TAG directives, and files whose aliases add more than 64 Ki nodes and value bytes or reference their own anchor. Assisted-by: Claude Code:claude-opus-5-5
Decoders never expand a sequence that lists itself, like `license: &loop [*loop]`, so only reject other self-references, which can decode their enclosing anchor once per reference. Assisted-by: Claude Code:claude-opus-5-5
wxiaoguang
reviewed
Oct 4, 2026
| } | ||
|
|
||
| const ( | ||
| maxFileSize = 256 * 1024 // parsing takes up to ~1000x the input |
Contributor
There was a problem hiding this comment.
The limit is here
content, err := entry.Blob(ctx.Repo.GitRepo).GetBlobContent(ctx, setting.UI.MaxDisplayFileSize)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rendering a CITATION.cff could use memory far out of proportion to the file, as every YAML alias copies its target into the formatted citation and the parser copies
%TAGprefixes into every node. Files past these limits show no citation, like unparseable ones do today.%TAGdirectivesMemory of one
FormatCFFcall:%TAG