Repository navigation
perf(analysis): share macro scopes across MacroVisibility resolvers - #11974
Conversation
…11948) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 51 minutes. View limit details
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
|
…ath (#11948) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
There was a problem hiding this comment.
Independent review (fresh-context reviewer, head 3e550a2): REVIEW_INCOMPLETE
Inspected:
- The candidate's whole change: two files over base
56d273dc2-crates/ripr/src/analysis/facts/macro_visibility.rs(+68/-8) andchangelog.d/11948-share-macro-scopes-across-resolvers.md(+2/-0). It adds a process-global, pointer-keyed cache of derived macro scopes:static SHARED_SCOPES: Mutex<Option<HashMap<usize, (Weak<str>, Option<Arc<MacroScope>>)>>>, capped atSHARED_SCOPE_ENTRIES = 16_384, consulted byshared_scope(source)and by the resolver's per-filescope()lookup. The stated purpose is in the changelog fragment and the design comment: the facts pass and the classifier each build aMacroVisibilityover the same sources, each resolver (and each clone) starts with an empty memo, so every Rust file was parsed again for each - about three parses of 1,730 files on servo. - The keying hazard, which is the load-bearing design question here, and it is handled correctly. The cache is keyed by the address of the
Arc<str>allocation (Arc::as_ptr(source).cast::<u8>() as usize), which is the classic ABA setup: a freed allocation's address can be reused by a different one. The defense is theWeakvalidation on lookup -weak.upgrade().is_some_and(|live| Arc::ptr_eq(&live, source))- and it is airtight for the reason it should be.Arc::downgradekeeps the control block alive, so a freed allocation'sWeakcannot upgrade, and a reused address therefore producesNonefromupgrade()and misses the cache; and when the address is reused while the old control block is still alive,Arc::ptr_eqcompares the new allocation against the old one and rejects it. A cache miss costs a re-parse, never a wrong scope, provided that validation holds. I checked the two places it could be bypassed and it is not: the lookup validates on every hit, and the storedWeakis alwaysArc::downgradeof the source it was derived from. - That sharing the derived scope is safe, which is the second question the change has to answer.
MacroScopeispub(crate) struct MacroScope { macros: Vec<ScopedMacro>, modules: Vec<ScopedModule>, uses: Vec<ScopedUse>, export_opaque: bool, opaque: bool }incrates/ripr/src/analysis/syntax/macro_scope.rs- plain data with no interior mutability, noRefCell,Cell,MutexorOnceCell. Two resolvers holding the sameArc<MacroScope>therefore observe the same immutable value, which is what the previous one-Arc-per-resolver behaviour produced as well.ScopedMacrois likewise plain (name,offset,text,exported). Sharing is sound. - That the layering is right. The per-instance memo is still consulted first -
scope()checksself.scopesbefore falling through to the shared cache - so the shared cache is only reached on a per-instance miss. The expensive work happens outside the lock:macro_scope(source)is called beforeSHARED_SCOPES.lock()is taken, so concurrent resolvers do not serialize on the parse. The lock is held only for a map lookup and a map insert. Two threads that race on the same key both parse and both insert; the second insert overwrites with an equal value, which is benign. - That the error path is preserved and improved. The old code was
for scoped in macro_scope(source).unwrap_or_default().macros; the new code islet Some(scope) = shared_scope(source) else { continue; }followed byfor scoped in &scope.macros. An unparseable file previously produced an empty scope and an empty iteration; it now producesNoneand a skipped iteration - the same outcome. The negative result is also cached (Option<Arc<MacroScope>>), so a file that fails to parse is not re-parsed on the next resolver. - The oracle, and what it does and does not pin.
resolvers_over_one_source_share_its_scopeasserts both halves of the keying contract: two resolvers built over the sameArc<str>return scopes that areArc::ptr_eq, and a resolver built over a separately allocatedArc::from(&*source)- same text, different allocation - returns a scope that is notptr_eq. Both assertions are discriminating, and the second one is the one that would catch a change from pointer keying to text keying. - The hosted state at this head. Exactly one workflow ran:
Merge-ready Conflict Notice,success. NoCIrun and noMerge-ready requestrun exist for this head, so no Rust lane ran at all - themerge-readylabel was never applied. The only red context on the pull request ismerge-ready conflictwithstate=FAILURE, which is the base-conflict re-check, matching the reported merge stateDIRTY. The requiredRipr Rust Small Resultcontext is absent rather than green, and no implementation or test result exists at this head.
Blocking:
- None found. The change is a correct, well-scoped cache, the two hazards it introduces - address reuse and shared mutable state - are both properly defended, and the negative result is cached alongside the positive one.
- One landing-readiness item, not a candidate defect: the branch is
DIRTYagainst its base (themerge-ready conflictcheck is the one red context), and the requiredRipr Rust Small Resultcontext is absent because no Rust lane ran at this head.
Non-blocking:
- The cache's eviction is a live-set filter with a full clear, and it is O(cap) per insert once the cap is reached. When
map.len() >= SHARED_SCOPE_ENTRIES, the code doesmap.retain(|_, (weak, _)| weak.strong_count() > 0)and, if the map is still at the cap,map.clear(). Both operations are O(cap) over 16,384 entries, and they run on every insert past the cap. On servo - 1,730 files per this pull request's own receipt - the cap is an order of magnitude away, so this path does not execute. But a repository holding more than 16,384 simultaneously-live sources would pay an O(cap)retainplus an O(cap)clearper file, i.e. O(files x cap) across the run. It remains a net win, because each avoided parse is far more expensive than 16,384 hash-map operations, but it is not amortized O(1) and it is worth knowing before the same cache shape is reused on a larger corpus. A second-chance or epoch scheme, or simply a smaller cap with an LRU discipline, would keep the insert path O(1) amortized. - The cap bounds entries, not bytes. Each entry holds a strong
Arc<MacroScope>- the parsed macro table for one file - so 16,384 live entries is an unbounded-in-bytes amount of retained parse output, and the number was not derived from a memory budget. Theretainonly runs when the cap is hit, so scopes for sources that have since been dropped accumulate in between. TheWeakkeeps the source from being pinned, which is the right thing, but the derived scope is pinned strongly. If the intent is a memory ceiling rather than an entry ceiling, the retained value should be the one bounded. - A poisoned mutex silently disables the cache for the rest of the process. Both lock sites use
if let Ok(guard) = SHARED_SCOPES.lock(), so if a panic ever occurs while the lock is held, the mutex is poisoned,lock()returnsErrfrom then on, and every subsequent call takes the false branch: the scope is still derived correctly, so results stay right, but the cache is never written or read again and the optimization disappears with no signal.lock().unwrap_or_else(|poisoned| poisoned.into_inner())would recover it. The exposure window is small - the lock is held only across a map get and a map insert, never across the parse - so poisoning is unlikely, but the failure mode is silent and permanent, and a cache that silently stops working is harder to notice than one that fails loudly. - The receipt's own numbers are surprising and unexplained, and that matters for how the change generalises. The changelog fragment states that the cold pilot parsed 1,730 files three times each, that the macro-scope parsing was "62% of the bytes it parsed", and that sharing cuts the cold pilot about 6% - CPU 55.6 to 51.7 s and 57.2 to 53.1 s, wall 43.5 to 40.6 s and 44.9 to 42.1 s, two paired runs on a loaded 4-core box. If two of every three parses of every file were eliminated and the parsing was 62% of the bytes read, the time saving should be considerably larger than 6%. The most likely explanation is that the removed work was not on the critical path - the bytes were read and parsed, but the parse was cheap next to the rest of the analysis - which is a perfectly good outcome and arguably the most interesting finding here, because it means the duplicate parses were mostly not what the cold pilot spent its time on. But that reasoning is not in the receipt, and it is the part that decides whether the same change pays off on other repositories. A per-phase timing breakdown rather than a whole-pilot delta would settle it, and would cost nothing beyond the runs already being made for the paired comparison. I am not asserting the numbers are wrong; I am recording that they do not obviously follow from the stated model and that the gap is the interesting part.
- The ABA defense - the one failure mode here that would be a silent wrong answer rather than a slow path - is argued in the design comment but not pinned by a test. The test covers "same allocation shares" and "different allocation with the same text does not share"; neither forces an address to be reused, so a regression that dropped the
weak.upgrade()/ptr_eqvalidation would keep both tests green. That regression would be fail-open: a scope derived from a different file could be returned for a reused address, which would make a macro appear invisible or mis-scoped. Address reuse is awkward to force deterministically, but the property can be pinned without it by testing the lookup helper directly - that a key whoseWeakno longer upgrades yieldsNoneand does not return the stored scope - which needs no address manipulation at all. - One small regression inside the optimized path:
generators.insert(scoped.name.clone())replaces what was a move (generators.insert(scoped.name)) with a clone, so each matching macro now allocates a freshStringwhere the scope already owned one. It is immaterial next to the parse it sits behind, but it is a new allocation in the code this change exists to make cheaper, andScopedMacro.namecould be inserted by reference or the scope could hand out an owned name deliberately. - On efficiency, in summary: the change removes redundant work rather than adding any. Before, each source was parsed up to three times per run (the facts pass, the classifier, and each resolver clone); after, each distinct
Arc<str>allocation is parsed once. The lookup is O(1) - a hash of an integer key plus aWeak::upgradeand anArc::ptr_eq- and the parse, which is the expensive part, is outside the lock. The remaining costs I could find are the eviction path and the retained scopes described above; I found no unbounded growth, no quadratic behaviour, no new I/O, no process spawning, no cache-keying mistake and no memory growth beyond the bounded-but-not-byte-bounded entry set. On the semantic side the change is a pure cache: the derived scope is the same content either way, so a miss costs time and not correctness - with the ABA case as the one exception, and that is defended.
Not run:
- The Rust toolchain on this host is not on
PATH: I ran no test, clippy, fmt, orcargo xtaskgate. I did not reproduce thecargo xtask precommitresult the pull request claims, and I did not run the new test. - No hosted Rust lane ran at this head: the only workflow that ran was
Merge-ready Conflict Notice, so the exact-head workspace result is unobserved rather than green, and the pull request's servo pilot receipts are the only performance evidence I have. I did not reproduce those runs. - I could not execute the new test, so my reading of the eviction and poisoning behaviour is from the source and not from an observed run; in particular the claim that the cap is never reached on servo rests on the receipt's file count, not on a measurement I made.
- I did not run a combined-tree compile of the merged base and head.
Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head 3e550a2ca5267ce347d752e037b33c0cb66924f6. Not an approval.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
…rom #11975 (main red) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
…o matched Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
|
Generated by Claude Code |
There was a problem hiding this comment.
Verification questions
- Confirm the cache's cap and eviction behavior are untested, including whether a newly derived scope remains usable after another source causes eviction.
- Confirm the new sharing test observes scope pointer identity, not that the second resolver avoided reparsing.
- Confirm the adjusted declaration test now expects two parses, but does not identify which two sources were parsed.
- Confirm a poisoned SHARED_SCOPES mutex permanently disables sharing, because both lookup and insertion use if let Ok(lock) and silently continue without repairing the poisoned state.
- Confirm the process-global cache can be affected by test execution order, but existing tests only assert aggregate parse counts and pointer sharing.
- Confirm concurrent access to the process-global cache and scope derivation is not exercised by the changed tests.
- Confirm the global cache is process-wide and mutable, so stale, poisoned, or concurrently evicted entries require explicit isolation and stress coverage.
Evidence gaps
- The performance claim compares cold-pilot outputs only apart from paths, hashes, and timestamps, but the changed source does not expose the referenced receipt contents or verify artifact equivalence.
- No completed cargo-test receipt or focused concurrent/cache-pressure witness is available to validate the new global-cache behavior.
- Full executable validation remains incomplete because cargo-test has no receipt and ripr failed with exit code 2.
- Model proof intent was rejected by deterministic validation.
- The changelog's 6% performance improvement is supported only by two paired runs on a loaded four-core box, while equivalence is asserted apart from paths, hashes, and timestamps.
…try guard (#11948) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
There was a problem hiding this comment.
Independent review (fresh-context reviewer, head 8c534d3): REVIEW_INCOMPLETE
This is a re-bind. An independent review already exists on this PR bound to 3e550a2ca5267ce347d752e037b33c0cb66924f6, which reported REVIEW_INCOMPLETE with no blocking defect and five non-blocking findings. The head has since moved. This review covers the delta and states, per earlier finding, whether it still holds, has been repaired, or is stale. It does not supersede the earlier review; it binds to the head below.
Inspected:
- Head
8c534d3bb9542d0755b87c5737d716f57e1a3652; not draft;mergeable: MERGEABLE,mergeStateStatus: BLOCKED; labelmerge-readypresent; title "perf(analysis): share macro scopes across MacroVisibility resolvers". - The candidate's contribution against merge base
ad8b265b821f2380f15cb6ea859214b46b2c9788is now 4 paths, +76/-13:changelog.d/11948-share-macro-scopes-across-resolvers.md(+2/-0),crates/ripr/src/analysis/facts/macro_visibility.rs(+80/-13),crates/ripr/src/analysis/facts/macro_visibility/declaration_tests.rs(+6/-6, new module) andpolicy/process_allowlist.d/11720-first-pr-run-chain.txt(+3/-0, new file). The head-to-head delta3e550a2ca..8c534d3bbis 947 paths, but that is main's advance; the candidate's own change since the previously reviewed head is the text-gate work inmacro_visibility.rs, the newdeclaration_tests.rsmodule, and the allowlist file. - The change the delta makes.
MacroVisibility::attributedmoves fromOnceLock<BTreeMap<String, BTreeSet<PathBuf>>>toSyncMemo<BTreeMap<String, Arc<Vec<PathBuf>>>>(:63,:123,:311), i.e. from one whole-workspace index built once to a per-name, lazily resolved memo. A new text gatemay_declare_module_named(source, name, attributed)(:165) decides from raw text whether a file could declaremod name;at all, so a file that cannot spell the declaration is never parsed. A newattributed_elsewhere(name, file)(:646) replaces the index lookup and stops the scan at the second confirmed declarer, on the reasoning that two distinct files always include one that is notfile. A test-onlythread_local!counterSCOPE_PARSES(:38) counts parses so the new tests can assert the count. - The new oracle in
crates/ripr/src/analysis/facts/macro_visibility/declaration_tests.rs:resolving_one_file_parses_only_files_that_can_declare_its_modulesasserts exactly 2 scope parses for a 53-file workspace and 0 for a repeat ask;the_lookup_matches_the_whole_workspace_indexis a differential test that comparesattributed_elsewhereagainst a whole-workspace reference index over 27 contrived sources x 4 names x 3 files, includingmod r#cases;,mod\u{200e}cases;,pub (in crate) mod cases;,#[doc = "a]b"] #[cfg(feature = "x")] mod cases;and#[path = "a[0]"] mod cases;;the_text_gate_never_hides_a_declaration_the_parser_listscross-checks the gate against the parser's own module list over a name x gap x prefix grid and asserts more than 100 declarations were checked;the_attributed_lookup_stops_at_the_second_declarerpins the early stop;the_text_gate_keeps_every_contrived_attributed_declarationpins 17 contrived attributed forms. crates/ripr/src/analysis/facts/macro_visibility.rsat this head: the shared cache is unchanged in its load-bearing parts —SHARED_SCOPE_ENTRIES = 16_384(:88),SHARED_SCOPES.lock()at:93and:104both stillif let Ok(...), the validationweak.upgrade().is_some_and(|live| Arc::ptr_eq(&live, source))at:96-97, the storedArc::downgrade(source)at:112, the evictionmap.retain(...)/map.clear()at:106-109, andgenerators.insert(scoped.name.clone())at:303.- Hosted evidence at this head (57 contexts):
Ripr Rust Small on GitHub Hosted / Rust gates(job 124705557418) FAILURE with the gate tableFORMATTING_RESULT: success,PRECOMMIT_RESULT: success,PROCESS_POLICY_RESULT: success,ALL_FEATURES_CHECK_RESULT: success,CLIPPY_RESULT: success,GOLDENS_RESULT: success,FIXTURES_RESULT: success,CAPABILITY_PRODUCERS_RESULT: success,CAPABILITY_DOCS_RESULT: success,VERDICT_CORPUS_RESULT: failure,RUST_TESTS_RESULT: skipped;Rust-only feature lane(job 124705378633) FAILURE withtest result: FAILED. 12889 passed; 1 failedand a second grouptest result: FAILED. 619 passed; 2 failed;Ripr Rust Small Result(the required status check onmain) FAILURE and present;ub-reviewCANCELLED.
Earlier findings, re-disposed:
- "No blocking defect: the change is a correct, well-scoped cache, and the two hazards it introduces — address reuse and shared mutable state — are both properly defended" → STILL HOLDS for the cache half, and the delta extends the design rather than weakening it. The
Weakupgrade plusArc::ptr_eqvalidation is unchanged at:96-97and the storedWeakis stillArc::downgradeof the source it was derived from at:112, so a reused address still misses rather than returning a foreign scope. The delta adds a second, orthogonal optimization — a text prefilter — and it is also fail-closed in the same direction: every case the gate cannot model (a comment, a non-ASCII byte, a keyword, an attribute it does not recognise, an unmodelledpub(..)form) returns "maybe" and forces the parse. - Landing-readiness — "the branch is
DIRTYagainst its base and the requiredRipr Rust Small Resultcontext is absent because no Rust lane ran at this head" → REPAIRED. The branch is nowMERGEABLEagainst its base and the required context is present at this head. - Non-blocking — "the cache's eviction is a live-set filter with a full clear, and it is O(cap) per insert once the cap is reached" → STILL HOLDS.
macro_visibility.rs:106-109is unchanged:map.retain(|_, (weak, _)| weak.strong_count() > 0)thenmap.clear()when still at the cap, both O(cap) over 16,384 entries, on every insert past the cap. The receipt's 1,730 files are an order of magnitude below the cap, so it does not execute there, but it is still O(files x cap) across a run on a larger corpus. - Non-blocking — "the cap bounds entries, not bytes; each entry holds a strong
Arc<MacroScope>" → STILL HOLDS.:88and:112are unchanged. - Non-blocking — "a poisoned mutex silently disables the cache for the rest of the process" → STILL HOLDS. Both lock sites are still
if let Ok(guard) = SHARED_SCOPES.lock()(:93) andif let Ok(mut guard) = SHARED_SCOPES.lock()(:104). A panic while the lock is held poisons it, every later call takes the false branch, and the scope is still derived correctly — so results stay right while the optimisation disappears with no signal.lock().unwrap_or_else(|poisoned| poisoned.into_inner())would recover it. The exposure window is small, because the lock is only held across a map get and a map insert and never across the parse, but the failure mode is silent and permanent, and a cache that silently stops working is harder to notice than one that fails loudly. - Non-blocking — "the ABA defense is argued in the design comment but not pinned by a test; a regression that dropped the
weak.upgrade()/ptr_eqvalidation would keep both tests green" → STILL HOLDS. The newdeclaration_tests.rsmodule tests the text gate, not the ABA path. The onlyptr_eqassertions in the tree are still the pre-existing pair at:1331/:1335("same allocation shares", "different allocation with the same text does not share"), neither of which forces an address reuse or exercises aWeakthat no longer upgrades. The earlier review's suggestion still stands: the property can be pinned without any address manipulation by testing the lookup helper directly — a key whoseWeakno longer upgrades must yieldNoneand must not return the stored scope. The failure mode there is a silent wrong answer rather than a slow path, which is why it deserves a test rather than an argument. - Non-blocking — "
generators.insert(scoped.name.clone())replaces a move with a clone, a new allocation in the code this change exists to make cheaper" → STILL HOLDS.:303is unchanged. - Non-blocking — "the receipt's numbers are surprising and unexplained: eliminating two of three parses of every file when the parsing was 62% of the bytes read should have saved considerably more than 6%" → STILL HOLDS, and the delta widens the gap. The changelog fragment is unchanged at +2 lines, so it still carries only the original receipt. The delta adds a second, different optimization — the text prefilter, which avoids parses entirely for files that cannot spell a declaration — and the fragment states no receipt for it at all. The interesting question the earlier review raised (whether the duplicate parses were on the critical path) is still unanswered, and now there is a second change whose effect is unmeasured. A per-phase timing breakdown would settle both, and the paired runs this PR already makes are the natural place to take it.
Blocking:
- None attributable to this candidate. The one gate that fails on the candidate's own lane is base-side, and I proved it with a same-base sibling rather than by argument (see below).
Non-blocking:
verdict-corpus check-allis red at this head, and it is base-side. The gate names exactly two cases:eq-divert-match-later-arm-old-constantandshop-tier-gold-arm-unreached, each "expectedobserved_verdict: \"limited\", gotobserved_verdict: \"gap\"". I did not take that on trust: #10240, whose head carries main'scrates/ripr/src/analysis/facts/macro_visibility.rsblob53bdc767e7434ad4054c6a1d072d672a63404ab9— byte-identical to main's, and therefore without this candidate's macro-visibility change — and the same stale committed rows, fails the same gate with the same two cases and the same expected/got values (job 124688421807). The drift therefore reproduces without the candidate, which places its cause on main. I traced it there: commit7972ca8f("fix(arm-selection): ignore inline test module use super::* for binding arms (#11950)") is an ancestor of main, changedcrates/ripr/src/analysis/classify/arm_selection.rsby +82/-13, and did not re-bless those two rows. The repair carrier is #11995, whose contribution re-blesses exactly these two rows fromlimitedtogap. Two earlier independent reviews in this campaign reached the same conclusion from the other direction, so this is corroboration rather than a new claim.- The
Rust-only feature lanefails three tests, none in this candidate's diff.lsp::backend::list_actionable_items_tests::list_actionable_items_names_gaps_the_actionable_profile_hidesis the known base-side red;check_worktree_drill_in_commands_reach_the_uncommitted_findingandselector_location_misses_explain_syntax_and_preserve_retry_scopeare also outside this candidate's four-path contribution.RUST_TESTS_RESULT: skippedon the Rust gates job is likewise unobserved rather than green. - The text gate is a correctness-bearing filter whose guarantee is empirical, not structural.
may_declare_module_nameddecides whether a file is parsed at all for an attributed-declaration lookup. A false negative there — a realmod name;with an attribute in a file the gate rejects — would make the lookup miss a declarer, so a macro would be treated as uniquely declared when the workspace says otherwise: a wrong analysis answer, not a slow path. The design is fail-closed (the gate returns "maybe" for every case it does not model) and the differential testthe_lookup_matches_the_whole_workspace_indexis the right shape of oracle, because it compares the fast path against a whole-workspace reference index rather than against a restatement of itself. But the gate is a hand-written second approximation of the lexer's rules —may_follow_attributemodels a barepub, a plainpub(...), and a tolerated attribute set, and treats everything else as a maybe — so every lexer rule it does not model is a chance for a silent false negative, and the tests pin a fixed, sampled matrix (27 contrived sources, and a name x gap x prefix grid yielding more than 100 parsed declarations) rather than proving the gate cannot hide a declaration. The cheapest strengthening is to derive the gate from the same lexermacro_scopeuses, or to make the differential test generate its source matrix rather than enumerate it; as it stands, the guarantee is broad but sampled. - Efficiency — the shape moved from "one index for all names" to "one full text scan per name". The old
attributed_declarations()built a singleBTreeMap<String, BTreeSet<PathBuf>>for every name in one pass over the sources. The newattributed_elsewhere(name, file)resolves one name at a time, so each distinct name asked costs a scan over every source's text —may_declare_module_nameddoessource.match_indices(name)across the whole file — making the worst case O(names x files x source_len) against the old O(files x source_len) parse-based index. The trade is in the right currency: a text scan is far cheaper than a parse, and it buys the early stop at the second declarer, which is where the win is. Two costs are worth naming. First, the memo is per-MacroVisibilityinstance —Cloneresets it (attributed: SyncMemo::default(),:123), so each clone re-runs the per-name scans, even though the sharedSHARED_SCOPEScache added by the earlier half of this PR is process-global and would serve exactly this. Second, the scan is a full-text substring search per name, so a workspace with many module names pays many full-file scans. Lifting the per-name result into the same shared-cache shape asSHARED_SCOPES— keyed by the name and the source set — would remove both costs at once. - Efficiency — the new parse counter cannot see a parse on another thread.
SCOPE_PARSESis athread_local!Cell, so it observes only parses on the thread that ran the test. The tests are single-threaded so this is correct for them, but the shared cache is a process-globalMutexshared across threads, so the counter's reach is narrower than the cache's. Worth knowing before anyone uses it as a general "how many parses happened" probe. - Duplicate-carrier note (verified by blob, not by issue number). The delta adds
policy/process_allowlist.d/11720-first-pr-run-chain.txtwith blob2402ccd29d575e911faa09697f7f303872ead9a5— byte-identical to the copy carried by #11975, #11942 and #11995. Its subject is #11720'sripr first-pr --run-chain: bothcrates/ripr/src/output/first_pr/run_chain.rsandcrates/ripr/tests/first_pr_run_chain.rsexist on main and both spawn processes, which is why main'scheck-process-policyis red. #11974 is a macro-visibility performance change with no connection to the run chain, so this file is a carried dependency, not part of this PR's claim; #11975 was already named the narrow survivor of that repair. Because the blob is identical there is no textual conflict, but the allowlist repair is now travelling inside four PRs, and the deciding criterion should be stated once rather than re-derived per PR: the entry belongs to whichever PR owns the spawning test file (#11970), with #11975 as the minimal carrier if #11970 does not take it. Nothing in this PR's own claim depends on it.
Not run:
- The Rust toolchain on this host is not on
PATH, so there was no local build, nocargo xtask precommit, no local test run, and no way to execute the new tests here. Every Rust-level statement above comes from the hosted job logs at this exact head or from reading source at this exact SHA. - I did not measure the new text gate's effect. The delta's own performance claim has no receipt, and I did not reproduce the fragment's paired servo runs, so I make no claim about how much the text prefilter saves relative to the shared-scope cache, nor whether it could regress any case the shared cache handled.
- The hosted Rust phase beyond the gates I quoted is unobserved at this head:
RUST_TESTS_RESULT,BASE_STILL_MERGES_RESULT,PR_EVIDENCE_RESULTandSCHEMA_SWEEP_RESULTare allskipped, andub-reviewwas CANCELLED at its substantive step. This review does not rest on them and does not claim they passed. - I did not execute the new
declaration_tests.rsmodule, so my reading of the gate's soundness is from the source and from the test matrix, not from an observed run.
Reviewed by an independent Mavis review agent on behalf of the maintainer; bound to head 8c534d3bb9542d0755b87c5737d716f57e1a3652. Not an approval.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmnpjseHB4bwBLfUmC5
|
Generated by Claude Code |
|
Review of record, head 326bd10 (COMMENT; helper review-burn-down) Evidence: the shard 2 SIGTERM failure (run 41269810524, 05:02Z) was infrastructure; the rerun on the same head completed Angles inspected (full diff read):
Findings: none material. Merging on the exact head. Generated by Claude Code |
Governing issue or accepted claim: #11948
Acceptance delta (one sentence): The facts pass and the classifier no longer each re-parse the same source to build its macro scope, cutting about 6% from the servo cold pilot with findings unchanged.
Change
MacroVisibilityresolvers memoizedmacro_scopeper instance, so the same source was parsed up to three times per run. A pointer-keyed, weak-validated shared cache (capped at 16,384 entries) lets resolvers over oneArc<str>share a single scope. An equal-text but separately allocated source does not share, which the test pins.Proof
cargo xtask precommitpasses.resolvers_over_one_source_share_its_scope.changelog.d/11948-share-macro-scopes-across-resolvers.md.Generated by Claude Code