Skip to content

Commit f4322f7

Browse files
committed
Lower similar-list decomposition threshold
AI-assisted change (OpenAI Codex).
1 parent d100c2b commit f4322f7

3 files changed

Lines changed: 47 additions & 14 deletions

File tree

PERF_RESEARCH_LOG.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,37 @@ Both changes are within the roughly 0.1% cross-binary layout noise. The pass
12631263
mostly performs required hash-table counting work, so eliminating only its
12641264
tree-walk control flow has little leverage. The source was fully reverted.
12651265

1266+
### exp39: lower the similar-list decomposition gate — KEPT at 45,000
1267+
1268+
Exp35 only attempted similar-list pairing when the product of the two section
1269+
sizes reached one million. A temporary trace showed that `slow` entered through
1270+
one 1.69M top-level section, while `typing` recursively paired sections from
1271+
1.06M to 5.10M but left plausible 0.40M and 0.48M sections untouched. A
1272+
compile-time sensitivity sweep lowered this single gate:
1273+
1274+
| graph-size gate | `slow` change | `typing` change | 107-pair output oracle |
1275+
| ---: | ---: | ---: | --- |
1276+
| 250,000 | flat | -0.103% | identical |
1277+
| 100,000 | flat | -0.145% | identical |
1278+
| 50,000 | -17.62% | -0.143% | identical |
1279+
| 45,000 | **-19.33%** | **-0.144%** | identical |
1280+
| 40,000 | -19.33% | -0.144% | `slider_1.rs` changed |
1281+
| 25,000 | -31.40% | -0.140% | `load_1.js` and `slider_1.rs` changed |
1282+
1283+
The cliff is discrete: lowering the threshold enables another recursive split,
1284+
not merely a little more preprocessing. The lowest tested exact-output setting,
1285+
45,000, was retained. Its final ten-run means against a copied exp37 control
1286+
were 642,765,789 to 518,537,235 instructions on `slow` and 2,828,226,154 to
1287+
2,824,159,538 on `typing`.
1288+
1289+
On `slow`, the number of searches rises from 8 to 17, but their total visited
1290+
vertices fall from 224,960 to 144,260 (**-35.87%**) and the largest search falls
1291+
from 63,774 to 42,265 vertices (**-33.73%**). This confirms that many smaller
1292+
searches are substantially cheaper than a few medium dense ones. Output is
1293+
byte-identical in side-by-side, inline, and JSON modes on all 107 available
1294+
sample pairs. `cargo test` passes (163 passed, one ignored), and the changed
1295+
file passes `rustfmt --check`.
1296+
12661297
## Where this leaves things
12671298

12681299
| workload | earlier reference | now | change |
@@ -1271,8 +1302,8 @@ tree-walk control flow has little leverage. The source was fully reverted.
12711302
| trivial Rust diff, master through query work | 444,668,795 | ~206,000,000 | **-54%** |
12721303
| `huge_cpp`, before exp17 through exp22 | 14,858,905,910 | 9,285,036,692 | **-37.5%** |
12731304
| `huge_cpp` peak RSS, exp21 through exp22 | 696 MB | 491 MB | **-29%** |
1274-
| focused `typing`, exp22 through exp37 | 3,115,140,742 | 2,828,276,712 | **-9.21%** |
1275-
| focused `slow`, exp22 through exp37 | 1,881,539,982 | 642,755,405 | **-65.84%** |
1305+
| focused `typing`, exp22 through exp39 | 3,115,140,742 | 2,824,159,538 | **-9.34%** |
1306+
| focused `slow`, exp22 through exp39 | 1,881,539,982 | 518,537,235 | **-72.44%** |
12761307

12771308
The large-input pass found a different class of wins from the original suite:
12781309
quadratic display loops (exp13-17), redundant offset-to-line searches (exp19),
@@ -1281,7 +1312,7 @@ The post-exp22 `huge_cpp` profile is now led by line splitting, Imara histogram
12811312
diff construction, allocator traffic, and changed-region line conversion; the
12821313
previous hunk-end and opposite-line hash hotspots are gone.
12831314

1284-
The focused exp23-37 pass first found small, composable wins in slider range
1315+
The focused exp23-39 pass first found small, composable wins in slider range
12851316
collection and parent-stack dispatch, then a much larger win by decomposing
12861317
oversized graphs at similar sibling lists. It also ruled out three tempting
12871318
graph directions on the exact target inputs: regenerating cached neighbours,

plan.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ new incremental experiment, use the latest accepted branch tip as the control.
241241

242242
Fresh five-run `perf stat` means at the start of the focused pass:
243243

244-
| pair | post-exp22 instructions | latest accepted after exp37 | cumulative change |
244+
| pair | post-exp22 instructions | latest accepted after exp39 | cumulative change |
245245
| --- | ---: | ---: | ---: |
246-
| `typing` | 3,115,140,742 | 2,828,276,712 | **-9.21%** |
247-
| `slow` | 1,881,539,982 | 642,755,405 | **-65.84%** |
246+
| `typing` | 3,115,140,742 | 2,824,159,538 | **-9.34%** |
247+
| `slow` | 1,881,539,982 | 518,537,235 | **-72.44%** |
248248

249249
The original focused callgrind files were `/tmp/cg-focused-typing.out` and
250250
`/tmp/cg-focused-slow.out`; sampled cycle profiles were
@@ -347,6 +347,7 @@ than mixing counts across environments.
347347
| 36 | initialise sibling and predecessor links in one syntax traversal | -0.16% `typing`, flat on `slow` | kept |
348348
| 37 | initialise parent, ancestor depth, and preorder ID in one traversal | -0.16% `typing`, -0.10% `slow` | kept |
349349
| 38 | count content IDs during content-ID assignment | -0.07% `typing`, flat on `slow` | rejected |
350+
| 39 | lower similar-list graph-size gate from 1,000,000 to 45,000 | -19.33% `slow`, -0.14% `typing` | kept |
350351

351352
Every completed experiment is committed and pushed. `results/` holds labelled
352353
callgrind tables through `exp13-linear-visible-width`; experiments that only
@@ -355,9 +356,9 @@ affect inline, JSON, or synthetic/very-large shapes use repeated targeted
355356
`huge_cpp` pair from 14.86B to 9.29B instructions (**-37.5%**), and exp22 also
356357
reduced its peak RSS from 696 MB to 491 MB. If the compiler, dependencies,
357358
profiler, or machine changed, record a fresh control binary before comparing.
358-
The focused exp23-37 pass reduced `typing` from 3.115B to 2.828B (**-9.21%**)
359-
and `slow` from 1.882B to 0.643B (**-65.84%**). Exp35's similar-list pairing is
360-
responsible for most of that improvement.
359+
The focused exp23-39 pass reduced `typing` from 3.115B to 2.824B (**-9.34%**)
360+
and `slow` from 1.882B to 0.519B (**-72.44%**). Exp35's similar-list pairing and
361+
exp39's lower decomposition gate are responsible for most of that improvement.
361362

362363
## Research synthesis: where larger wins can come from
363364

@@ -575,9 +576,10 @@ percentages above predate exp25-31.
575576

576577
1. **Characterise and tighten similar-list pairing.** Exp35 kept the pairing +
577578
descent combination after byte-identical output on all 107 available sample
578-
pairs. Measure the one-million product gate and vote thresholds one at a
579-
time, including values that disable pairing on `typing` or split `slow` more
580-
finely. Do not weaken ambiguity or non-crossing guards merely for speed.
579+
pairs. Exp39 swept the graph-size gate and retained 45,000: 40,000 changed
580+
`slider_1.rs`, while 25,000 also changed `load_1.js`. Measure the minimum
581+
common-unique vote threshold next, one value at a time. Do not weaken
582+
ambiguity or non-crossing guards merely for speed.
581583
2. **Add low-overhead search-shape instrumentation.** Counters should be
582584
compile-time- or log-gated and excluded from timed release measurements.
583585
Attribute which edge types create and settle the million-state `slow`
@@ -658,7 +660,7 @@ percentages above predate exp25-31.
658660
rather than comparing across machines or toolchains.
659661
5. Choose one hypothesis from the prioritised backlog, state whether it is in
660662
the exact-output or diff-quality lane, change one thing, measure both pairs,
661-
and immediately append exp39 (then exp40, etc.) to
663+
and immediately append exp40 (then exp41, etc.) to
662664
`PERF_RESEARCH_LOG.md` and the state table here.
663665
6. Fully revert rejected source changes with `apply_patch`, but commit and push
664666
their log entries. For a kept change, run the wider output oracle and full

src/diff/unchanged.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const MOSTLY_UNCHANGED_MIN_COMMON_CHILDREN: usize = 4;
1313

1414
/// Only attempt to decompose a possibly-changed section further when the graph
1515
/// size would otherwise be at least this big.
16-
const OVERSIZED_SECTION_MIN_GRAPH_SIZE: u64 = 1_000_000;
16+
const OVERSIZED_SECTION_MIN_GRAPH_SIZE: u64 = 45_000;
1717
/// A list smaller than this only needs to share one unique subtree with another
1818
/// list to be paired with it.
1919
const SIMILAR_LIST_MIN_DESCENDANTS: u32 = 20;

0 commit comments

Comments
 (0)