Repository navigation
perf(driver): eliminate tree-shake double-decode, chunk par_map, and optimize V3 cache-hit path - #473
Merged
Merged
Conversation
…optimize V3 cache-hit path
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.
Summary
Driver- and oracle-only compilation speedups targeting
tree_shake+decodeand theV3cache-hit path, plus closing all 5 P3 follow-ups from #466. No changes tocrates/beamc-core/**,crates/beamrt/**, orproofs/**.Performance optimizations (
crates/beamc-driver/**).beamdecoding after tree-shaking (treeshake.rs,module_reflection.rs,lib.rs,main.rs):tree_shake_beams_with_decodedreturning the already-decodedBeamModules for kept modules (background-dropping prunedBeamModules andModuleIndextables), and reuse them directly indecode_with_func_maskswithout decoding all kept.beamfiles a second time.mfa_to_func: HashMap<(String, u32), usize>withHashMap<String, Vec<(u32, usize)>>(lookup_mfa) to eliminate per-lookupStringallocations during the tree-shake BFS.label_posinsideextract_module_indexonly whenOP_TRYor localOP_CALLis encountered.par_map(pipeline.rs):cursor.fetch_add(1)+ full-elementsort_unstable_by_keywith safe chunked work-stealing (chunk = 64for large inputs), sorting only chunk headers and avoidingO(N log N)moves of largeRvalues.wf_check_parand fusedV3.check_final(pipeline.rs):idx: Vec<usize>+Resultvector allocations inwf_check_parwhile preserving exact first-error-in-function-order semantics.V3.check_final(wf::check_function,verify_function,soft_rt_ok_one) into a single chunked parallel pass with cache-line-paddedAlignedAtomicUsizeto avoid false sharing.pack.getinv3_planandpar_scalarshell refresh (pipeline.rs):pack.get(&key)insidepar_mapinv3_plan.refresh(ro)on freshly constructedShell::new(ro)instances inpar_scalar, raiseCHUNKto 64, and skip all-cached chunks whenskip.is_some().Follow-ups from #466 (5 P3s)
cas.rs): Manualimpl Hash for CacheKey(state.write(&self.0)) +cache_key_hasher_distinct_keysunit test.lib.rs): Replace(use_oracle && cache.is_some()).then(...)withcache.filter(|_| use_oracle).map(...).lib.rs): Extractscan_function_reachabilityand addprune_unreachable_functions_matches_core_callgraphguardrail test againstbeamc_core::opt::callgraph::{address_taken, callees}.beamc-oracle/src/type_infer.rs): Removedebug_assert_eq!atTailCallDirectso malformed SSA does not panic in debug builds beforewf_check_par.beamc-oracle/src/type_infer.rs): Expandbsp_type_infer_deterministic_across_thread_countsto 339 functions (256 roots + 80 mid-layer forwarders + merge + mutual recursion) across 1, 2, 4, and 8 threads.Verification
./scripts/check-aeneas-subset.sh— PASS./scripts/check-beamrt-ssot.sh— PASScargo clippy --workspace --all-targets -- -D warnings— PASS (0 warnings)cargo test -p beamc-core -p beamc-oracle -p beamc-driver— PASS (0 failed)31,207 ms -> 28,738 ms(-2,469 ms,-7.9%wall;tree_shake + decode1,220.5 -> 684.0 ms,-44.0%)Base -> New):24,954 ms -> 22,027 ms(-2,927 ms,-11.7%wall;V3.facts -29.9%,V3.fold -18.1%,V3.check_stages -26.6%,V3.check_final -6.4%)New -> Base):15,414 ms -> 14,304 ms(-1,110 ms,-7.2%wall;tree_shake + decode1,145.9 -> 698.4 ms,-39.1%;V3.facts -17.6%,V3.fold -13.0%,V3.check_stages -14.7%,V3.check_final -7.3%)696 ms -> 407 ms(pre-treeshake hit + link hit)BASE_EQ_NEW = YES,TS_WARM_IDENTICAL = YESOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.