Repository navigation
perf(core): always inline rule_matches into the generic evaluator (#72; #73 analysed) - #102
Merged
Merged
Conversation
Root cause of the 0.2.0 targeting slowdown, from disassembly of the release A/B harness: the evaluator became generic over its trace recorder and is instantiated twice (evaluate_variant and explain). rule_matches then had two callers and LLVM stopped inlining it (a plain #[inline] hint does not change that), so every rule of every evaluation paid a call. 0.1.31: one 1,800-instruction evaluator, rule_matches inlined. 0.2.0: evaluator 694 instructions plus an out-of-line rule_matches of 893, one call per rule. #[inline(always)] restores the 0.1.31 shape for the rule loop. No semantic change; core tests, bucketing tests and the shared evaluation vectors (explain included) pass unchanged. Local A/B (macOS, release_core_ab, B-C-C-B): targeting_10_rules vs 0.2.0 0.933 [0.903, 0.950]; other cases inconclusive at 1 %. The release gate needs the dedicated Linux host.
4 tasks
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.
Core performance for 0.2.1: this fixes the root cause of #72. It does not recover #73, and neither issue's ≤ 1.010 gate is met until the dedicated Linux host confirms it.
Root cause of #72
I disassembled the release A/B harness (
scripts/release-benchmarks/lib/core_ab.rs, built against each release):evaluate_variant_at_depthrule_matchesrule_matchesinlinedNoTraceforevaluate_variantandRecorderforexplain().rule_matchesgained a second caller, so LLVM stopped inlining it.#[inline]hint does not change this (verified: identical code).#[inline(always)]restores the 0.1.31 shape of the rule loop.#73 (weighted multivariate): root cause analysis, not fixed here
variants.get(index).(index, &variant), inlined;&variantwith the index computed lazily, only forexplain();prerequisite_chain_5by 5–12 % (CI excludes 1). Forms 1–2 enlarge the recursive evaluator; form 3 adds a call to every multivariate evaluation, and also slowedboolean.-align-all-functions=6 -align-all-nofallthru-blocks=5, experiment builds only), the chain cost stayed (×1.036 [1.004, 1.046]). So it is not only a layout artifact.Local A/B (macOS laptop; same harness, B→C→C→B rounds, ratio of medians with a 95 % bootstrap CI; indicative only):
With alignment forced: targeting_10_rules 0.917 [0.888, 0.962] vs v0.2.0, and prerequisite_chain_5 0.987.
Gates (#72 and #73: CI upper bound ≤ 1.010 against v0.1.31 on the dedicated host, and no other benchmark more than 1 % slower): not met yet. They need
scripts/release-benchmarks/v0.2.0-linux.sh --baseline v0.1.31 --candidate <this PR's head>on the dedicated Linux host, which I don't have. This laptop's run-to-run noise is several percent.Correctness: no semantic change. Core unit tests, bucketing tests and the shared evaluation vectors (
explain()included) pass.Refs #72, #73