perf: cut an adjudication's surface fingerprint and duplicate config parses - #1111
Merged
Merged
Conversation
`surface_fingerprint` ran every policy-surface file through `normalize_span`, which copies the text to replace `CRLF` and copies it again to collect its NFC form. `epoch::describe` fingerprints the surface on every hook adjudication, and that text is LF and NFC already, so both copies reproduced their input. Under callgrind, one mcp-surface `adjudicate` of the debug binary spent 719M of its 2,087M instructions there. `canonical_text` returns the input borrowed when it holds no `CRLF` and `is_nfc_quick` answers `Yes`, which is exactly the text the rewrite leaves unchanged; anything else takes the rewrite as before. `surface_fingerprint` hashes the borrowed bytes without copying them. `identity::tests::normalized_text_is_fingerprinted_without_a_rewrite` pins both halves: canonical input is borrowed, and ASCII, composed, decomposed, `CRLF` and lone-`CR` input all canonicalize to the rewrite's bytes. `nfc-fast-path-never` is killed by hand, and `engine-identity` joins `MUTANT_GATES`. Refs: CLOUD-2102
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 51 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
One `batten adjudicate` called `config::parse` three times over the same bytes: `resolve` loads the authority twice through `load_site`, and `epoch::authority` once more through `load`. Each call deserialized and validated all 583 KB. Under callgrind that was 435M of a 1,481M-instruction mcp-surface adjudication. `parse_remembered` answers from the last success when the text and source are byte-identical. The parse reads no environment and no file, so the answer is the same `Config`. `check_min_version`'s report stays outside, so it is still made on every load, and a refusal is never remembered. `config::tests::one_authority_is_parsed_once_per_process` counts parses through `config_parses()`: a repeat costs none, and another source or other bytes cost one each. `config-parse-unremembered` is killed by hand. Refs: CLOUD-2103
wenzowski
marked this pull request as ready for review
October 3, 2026 21:06
Contributor
Author
|
/fast-forward |
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.
Closes CLOUD-2102
Closes CLOUD-2103
Two per-spawn costs on the hook path, found under callgrind on one mcp-surface
adjudicateof the debug binary. Together they take it from 0.59 to 0.45 CPU-s per spawn.CLOUD-2102 —
perf(identity).surface_fingerprintrewrote every policy-surface file twice (CRLF→LF, then NFC collect) on every adjudication, and each rewrite reproduced already-canonical input. That was 719M of 2,087M instructions.canonical_textnow borrows text that has noCRLFand thatis_nfc_quickanswersYesfor; any other text takes the rewrite, so the output is byte-identical. Testnormalized_text_is_fingerprinted_without_a_rewrite, mutantnfc-fast-path-never, andengine-identityadded toMUTANT_GATES.CLOUD-2103 —
perf(config). One adjudication parsed the same 583 KBbatten.tomlthree times: twice fromresolveand once fromepoch::authority. That was 435M of 1,481M instructions.parse_rememberedanswers from the last successful parse when the text and source are identical. The min-version report is still made on every load, and a refusal is never cached. Testone_authority_is_parsed_once_per_process, mutantconfig-parse-unremembered.Both mutants were killed by hand.
🤖 Generated with Claude Code
https://claude.ai/code/session_01SFeJfGnT67NjjLWQJ1SgXB