docs: step 1 measurements (stats build) in mcgs-log

mcgsstats 1000, 5000 and 5000 16, plus an extra no-GC run at Hash 1024
for the edges-per-node growth ratio. Derived bounds, the ValueHash
cross-check (leaf_tt 54-66 % overall, inside 37-85 %) and the arena
split input for step 2. Stats-build numbers, local machine.

Bench: 663779

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rektdieandclaude committed 2026-11-16 19:23:37 +01:00
1 parent fc0a3a8fec
commit 479f6cfb2f
1 file changed
+269
+269
View File
@@ -5,3 +5,272 @@ only from results the owner provides.
| step | branch | commit | bench | SPRT (link, TC, bounds) | outcome |
| --- | --- | --- | --- | --- | --- |
| 1 | `mcgs-stats` | `bec9871` | 663779 (normal and `STATS=1` builds) | none (never merged) | measurement only; the branch stays on its own |
## Step 1 measurements
All numbers below come from the **stats build** (`make STATS=1`) at `bec9871`, on
the owner's Windows machine, 2026-11-16. Rates, cycle shares and playouts per
second are local measurements of that build. They say nothing about strength.
**Stats-build overhead.** The key maps and timers slow the search down. Over the
16 positions, the normal build ran:
- 811k playouts/s at 1000 ms (12.7M playouts);
- 770k playouts/s at 5000 ms (61.3M playouts).
The stats build ran 498k/s and 474k/s, about 61 % of that. A stats-build
5000 ms tree is about the size of a normal-build 3 s tree.
**Definitions** (plan section 4, with these choices made explicit):
- A *tree node* is a node MCGS would create: the root, plus every
first-visited position that is not a path-dependent draw. Repetition and
50-move leaves are never graph nodes, so they are not counted.
- `newleaf` = playouts that end at such a first visit.
- `lf_tt` (`leaf_tt`) = new leaves whose key already had a tree node, as a
percentage of new leaves. That is the denominator the ValueHash comment uses
("leaf evaluations"). Per playout it is about 0.55× that.
- `vh` = ValueHash hits as a percentage of all first visits.
- `exp_dup` = expansions of a key that already had an expanded node, as a
percentage of expansions.
- `path_tt` = playouts with at least one path node whose key has ≥ 2 tree nodes.
`inner` is the same count without the new leaf.
- `dup` = tree nodes / distinct keys.
- `r_tree` = child slots / visited nodes: edges per node in the step 2 layout.
- `r_grph` = child slots counted once per distinct expanded key / distinct keys,
which approximates edges per node after merging.
- The key maps are rebuilt from the tree after root expansion, reroot and every
GC. The end-of-search figures are taken after the last GC.
Each run searched the 16 bench positions, each with a fresh `Searcher` (so no
reuse), at Hash 64 unless stated otherwise.
### `mcgsstats 1000` (Hash 64)
```
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
1 249792 254889 249757 51.8 34.0 50.8 47.8 95.8 95.0 11 0 1.965 15.74 17.14 1
2 171008 174497 170960 23.8 15.1 22.9 22.1 92.9 92.6 16 0 1.278 14.88 15.37 1
3 250240 255346 250197 56.4 38.1 56.1 53.0 89.6 88.4 41 0 2.080 13.04 14.37 2
4 277376 283036 277372 76.8 58.3 76.5 74.2 95.4 94.7 2 0 4.076 14.73 15.45 2
5 232512 237257 232455 40.4 25.7 39.2 36.1 87.0 85.3 56 0 1.605 16.64 17.95 1
6 202944 207085 201798 32.1 20.5 30.7 29.9 88.4 87.4 206 0 1.430 15.48 16.08 1
7 192064 195983 191629 30.0 18.6 29.0 28.8 89.0 88.2 392 0 1.386 16.16 16.71 1
8 199808 203885 199106 23.2 14.5 22.5 20.9 80.5 79.4 684 0 1.263 16.85 17.67 1
9 252928 258089 250454 39.8 25.7 37.6 36.6 91.9 91.0 2418 0 1.546 9.05 9.79 1
10 307136 313404 268891 41.7 29.4 36.7 38.6 96.3 96.0 37831 0 1.716 11.09 11.75 0
11 886848 904946 451555 91.2 78.0 86.3 90.5 100.0 100.0 432838 0 11.403 4.09 7.98 0
12 821440 838204 524144 91.2 82.4 86.5 89.4 99.9 99.8 296636 0 11.331 3.56 4.61 0
13 224384 228963 223701 24.5 15.0 21.5 22.1 74.6 72.8 616 0 1.325 13.93 14.44 0
14 244992 247716 243015 31.4 20.2 29.7 28.3 88.4 87.6 1975 0 1.379 11.49 12.22 2
15 679936 693812 672593 93.8 75.5 88.5 88.9 99.7 99.6 6524 0 14.199 3.09 7.59 1
16 2625600 2679183 14470 34.0 21.3 32.7 29.9 99.3 99.3 2562358 0 1.515 12.70 13.58 0
all 7819008 498375 4422097 60.1 46.5 57.4 56.2 96.0 95.6 3342604 0 2.536 9.47 14.03 14
```
### `mcgsstats 5000` (Hash 64)
```
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
1 1016192 204054 1015943 50.2 30.0 56.2 43.9 97.9 97.5 81 0 1.778 6.46 7.19 12
2 786880 156874 785729 19.9 10.8 24.0 16.3 96.6 96.5 535 0 1.210 6.26 6.44 9
3 1186880 238329 1186600 63.6 39.6 71.3 57.6 95.0 94.4 252 0 2.407 8.97 10.20 17
4 1244480 249895 1244387 73.5 50.5 80.4 67.0 97.6 97.3 77 0 3.885 9.09 11.53 16
5 1053568 211009 1052812 43.8 25.2 49.8 36.8 92.9 92.0 743 0 1.649 5.94 6.57 13
6 914112 183556 904648 33.9 19.1 36.8 28.1 94.3 93.9 4722 0 1.438 7.00 7.61 9
7 958720 192514 944891 31.5 18.2 37.0 27.4 96.1 95.8 13719 0 1.405 9.56 9.98 10
8 944000 189558 936972 22.9 12.5 28.0 18.4 92.4 92.0 6815 0 1.242 7.42 7.90 11
9 1159680 230828 1143522 40.5 25.2 42.0 35.0 93.9 93.3 15583 0 1.518 4.35 4.75 8
10 1658304 332992 1265760 51.5 34.4 47.7 43.9 99.1 99.0 389253 0 1.844 5.52 6.50 7
11 4141760 831678 1755422 92.2 78.4 86.9 90.5 100.0 100.0 2366999 0 12.889 2.80 6.53 4
12 3398208 682371 1913929 93.7 83.7 87.5 91.7 100.0 100.0 1307918 0 13.707 2.57 4.14 3
13 973888 195559 955354 27.2 15.4 28.6 22.3 89.5 88.9 14102 0 1.328 6.27 6.78 7
14 1050432 210930 1035983 27.2 14.8 32.5 21.1 94.5 94.2 14413 0 1.318 7.58 8.20 12
15 3230592 648713 3202909 96.0 78.0 90.9 89.9 99.9 99.9 24843 0 19.104 2.93 7.39 15
16 14102272 2831781 41850 40.1 25.6 38.1 35.1 99.9 99.8 13855364 0 1.670 12.31 13.34 0
all 37819968 474094 19386711 60.7 45.0 61.5 57.2 98.3 98.2 18015419 0 2.674 5.04 7.38 153
```
### `mcgsstats 5000 16` (Hash 16, GC-heavy)
```
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
1 1047040 210248 1046869 42.5 20.8 54.9 33.1 94.6 93.8 37 0 1.689 5.27 5.92 60
2 792384 159113 791393 15.4 6.8 24.6 10.7 96.4 96.2 378 0 1.219 3.98 4.12 41
3 1216576 243851 1216235 56.4 29.2 69.6 45.7 94.4 93.6 258 0 2.067 3.92 4.32 83
4 1238592 248713 1238497 63.9 36.2 76.5 54.4 97.0 96.5 16 0 2.992 6.02 7.54 79
5 1056896 211972 1055994 34.6 16.2 48.0 25.0 90.8 89.7 838 0 1.428 3.61 3.97 64
6 853312 171347 847890 15.9 7.1 27.9 10.8 93.8 93.3 2705 0 1.149 3.51 3.61 45
7 948608 190139 945462 27.8 14.0 39.4 21.2 97.1 96.8 2859 0 1.422 3.57 3.67 51
8 930112 186769 926062 14.7 6.9 29.2 10.1 89.1 88.5 3640 0 1.145 5.08 5.31 51
9 1138688 228652 1130927 28.9 15.0 37.8 21.7 89.0 87.9 7255 0 1.290 2.67 2.83 42
10 1390144 279145 1170515 38.4 20.6 36.6 27.7 98.7 98.6 215548 0 1.560 3.03 3.44 34
11 4220352 847460 1785559 89.4 74.6 84.0 86.6 100.0 100.0 2421567 0 11.163 1.27 2.38 25
12 3396352 681998 1876547 89.9 75.6 81.8 85.2 100.0 100.0 1494614 0 8.520 1.83 3.00 24
13 980480 196883 960668 18.4 9.0 29.6 13.1 86.2 85.5 14413 0 1.152 3.95 4.18 37
14 1125632 225622 1093084 23.9 10.8 36.7 16.2 93.4 93.0 32457 0 1.279 3.19 3.39 61
15 3027584 607948 3012539 93.1 65.9 81.6 79.3 99.9 99.9 13000 0 9.931 1.59 5.07 67
16 14088960 2829108 41827 40.2 25.7 34.5 35.3 99.9 99.8 13842528 0 1.673 12.29 13.33 0
all 37451712 469831 19140068 53.6 35.9 57.6 48.9 97.7 97.5 18052113 0 2.162 3.09 4.25 764
```
### Extra: `mcgsstats 5000 1024` (no GC)
Not in the plan. GC prunes child slots, so the end-of-search `r` at Hash 64
(153 GCs) is a post-pruning figure. At Hash 1024 no GC happens, and `r` is the
ratio at which an arena fills.
```
pos playouts po/s newleaf lf_tt tt_exp vh exp_dup path_tt inner rep r50 dup r_tree r_grph gc
1 1108224 222534 1107765 58.2 41.7 56.9 55.7 98.3 98.0 77 0 2.391 18.88 19.93 0
2 797824 160205 794007 18.7 11.5 18.3 17.5 97.4 97.3 2446 0 1.231 20.02 20.27 0
3 1261888 253391 1261542 71.8 57.0 70.8 70.1 95.2 94.8 270 0 3.546 20.37 21.55 0
4 1263936 253802 1263722 77.1 62.6 76.4 76.1 97.9 97.7 214 0 4.373 20.66 21.31 0
5 1150592 231042 1149845 53.9 38.8 52.4 51.3 94.6 93.9 747 0 2.168 19.50 20.45 0
6 972288 195238 967436 39.8 27.2 38.8 38.0 94.4 93.9 2466 0 1.660 19.58 20.01 0
7 994816 199762 994059 41.5 28.7 40.4 40.5 97.7 97.5 554 0 1.709 19.98 20.18 0
8 972480 195277 966716 26.4 17.0 25.8 24.6 92.8 92.3 5155 0 1.359 20.98 21.51 0
9 1183744 237699 1162150 42.6 28.8 41.9 39.8 96.0 95.5 20460 0 1.743 13.17 13.81 0
10 1859456 373384 1267715 55.9 42.9 54.2 53.1 98.5 98.4 586712 0 2.268 10.90 11.72 0
11 4432384 890036 1785406 93.7 83.5 89.6 93.1 100.0 100.0 2625372 0 15.750 4.41 8.97 0
12 3578688 718612 2007906 94.5 86.8 90.8 93.5 100.0 100.0 1367082 0 18.339 3.59 5.31 0
13 1042880 209413 1022986 31.7 21.7 30.9 29.5 89.2 88.5 15776 0 1.465 14.12 14.90 0
14 1226432 246271 1212002 39.7 28.1 38.7 37.7 96.5 96.3 14361 0 1.658 19.99 20.44 0
15 4031168 809471 3983269 98.0 89.9 96.6 96.6 100.0 99.9 44174 0 49.578 5.45 9.66 0
16 14052352 2821757 41766 40.1 25.6 39.4 35.1 99.9 99.8 13806006 0 1.669 12.29 13.33 0
all 39929152 501118 20988292 66.0 54.8 64.6 63.8 98.5 98.4 18491872 0 2.938 13.04 18.13 0
```
### Totals
| counter | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
| --- | ---: | ---: | ---: | ---: |
| playouts | 7,819,008 | 37,819,968 | 37,451,712 | 39,929,152 |
| new leaves (% of playouts) | 56.6 % | 51.3 % | 51.1 % | 52.6 % |
| `leaf_tt` (% of new leaves) | **60.1 %** | **60.7 %** | **53.6 %** | **66.0 %** |
| `leaf_tt` (% of playouts) | 34.0 % | 31.1 % | 27.4 % | 34.7 % |
| `leaf_tt_expanded` (% of new leaves) | 46.5 % | 45.0 % | 35.9 % | 54.8 % |
| `vh_hits` (% of first visits) | 57.4 % | 61.6 % | 57.6 % | 64.6 % |
| `leaf_tt_eval` (% of value calls) | 7.4 % | 13.2 % | 18.4 % | 2.1 % |
| value calls (% of playouts) | 23.7 % | 19.4 % | 21.3 % | 18.3 % |
| `exp_dup` (% of expansions) | 56.2 % | 57.2 % | 48.9 % | 63.8 % |
| `path_tt` / `inner` (% of playouts) | 96.0 / 95.6 % | 98.3 / 98.2 % | 97.7 / 97.5 % | 98.5 / 98.4 % |
| `rep_draws` (% of playouts) | 42.7 % | 47.6 % | 48.2 % | 46.3 % |
| `rep_draws` without position 16 | 780,246 | 4,160,055 | 4,209,585 | 4,685,866 |
| `r50_draws` | 0 | 0 | 0 | 0 |
| GC runs | 14 | 153 | 764 | 0 |
| `dup` (tree nodes / distinct keys) | 2.54 | 2.67 | 2.16 | 2.94 |
| visited / allocated | 10.6 % | 19.8 % | 32.4 % | 7.7 % |
| `r_tree` (edges per node) | 9.47 | 5.04 | 3.09 | **13.04** |
| `r_graph` (edges per distinct key) | 14.03 | 7.38 | 4.25 | **18.13** |
`tt_halfmove_hist`: the halfmove clock at `leaf_tt` hits, as a share of hits.
| halfmove | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
| --- | ---: | ---: | ---: | ---: |
| 0 | 22.5 % | 22.2 % | 21.0 % | 22.0 % |
| 1–3 | 28.4 % | 27.9 % | 26.0 % | 28.0 % |
| 4–7 | 36.5 % | 34.6 % | 38.6 % | 29.8 % |
| 8–15 | 12.4 % | 15.0 % | 14.0 % | 19.8 % |
| 16–31 | 0.24 % | 0.38 % | 0.38 % | 0.35 % |
| 32–63 | 0 | 0 | 0 | 0 |
| ≥ 64 | 0 | 0 | 0 | 0 |
Time split, as a share of `playout()` cycles (rdtsc, stats build). `vhash` is
also counted inside `backprop` (the store) and in leaf evaluation (the probe).
| part | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
| --- | ---: | ---: | ---: | ---: |
| value (net + qsearch) | 23.0 % | 18.9 % | 20.1 % | 18.2 % |
| policy | 13.9 % | 14.0 % | 15.5 % | 12.2 % |
| movegen | 5.4 % | 5.2 % | 5.5 % | 5.0 % |
| `select_child` | 28.0 % | 30.7 % | 28.8 % | 32.3 % |
| backprop loop | 11.1 % | 11.7 % | 11.1 % | 12.8 % |
| ValueHash probe + store | 6.2 % | 6.3 % | 5.9 % | 6.7 % |
| `make_move` | 5.3 % | 5.7 % | 5.6 % | 5.7 % |
### Derived bounds (stats build)
The table gives the search time MCGS could free, as a share of playout time.
`f_value` is applied per value call and `f_policy` per expansion, because
those are what the timers cover.
| | 1000 ms | 5000 ms | 5000 ms, Hash 16 | 5000 ms, Hash 1024 |
| --- | ---: | ---: | ---: | ---: |
| plan formula `f_value·max(0, leaf_tt − vh_hits)/value_calls + f_policy·exp_dup/expansions` | 8.96 % | 8.03 % | 7.59 % | 8.16 % |
| exact value term `f_value·leaf_tt_eval/value_calls + f_policy·exp_dup/expansions` | 9.52 % | 10.51 % | 11.28 % | 8.13 % |
| of which policy (`f_policy·exp_dup/expansions`) | 7.82 % | 8.03 % | 7.59 % | 7.75 % |
| cost upper bound `f_select + f_backprop` | 39.1 % | 42.4 % | 39.8 % | 45.1 % |
- **The saving is mostly policy, not value.** ValueHash already answers almost
every leaf transposition.
- The value evaluations MCGS would still skip (`leaf_tt_eval`: transposed
leaves that missed ValueHash) are 2–18 % of value calls.
- They grow with GC because ValueHash is small: 64 MB / 32 / 12 B ≈ 175k
entries, so entries get overwritten.
- About 55 % of expansions repeat an already-expanded key, and those policy
calls are what MCGS saves.
- **The plan formula's value term is 0 at 5000 ms (Hash 64 and Hash 16)**,
because `vh_hits > leaf_tt` there. After GC, ValueHash also answers positions
that GC dropped from the tree, which `leaf_tt` does not count. The exact
counter `leaf_tt_eval` is the right numerator, so the second row is the bound
to use.
- **The cost bound is loose.** `select_child` is about 30 % of playout time
today. The recompute per path node costs about one more `select_child` pass,
so the real added cost is below roughly 40 %. Steps 2 and 3 measure it. None
of these bounds covers what sharing subtree statistics is worth; only the SPRT
measures that.
- **Shared structure is everywhere.**
- 96–99 % of playouts pass through a node whose key has at least two tree
nodes.
- On average there are 2.2–2.9 tree nodes per distinct position.
- **Variant 5d (window key for halfmove ≥ T).**
- No `leaf_tt` hit had halfmove ≥ 32, and 0.24–0.38 % had 16–31. So T = 16
would lose under 0.4 % of the merges here, and T ≥ 32 none.
- That says little: every bench position starts with halfmove 0–8, so long
reversible stretches are under-represented. `r50_draws` is 0 for the same
reason.
- **Repetition draws are common: 43–48 % of playouts.**
- Position 16 (`6k1/6p1/8/6KQ/1r6/q2b4/8/8 w`) alone has 2.6M of the 3.3M at
1000 ms and 13.9M of the 18.0M at 5000 ms. It is a perpetual-check position
where 98 % of playouts end in a repetition.
- Without it there are still 0.8M (1 s) to 4.7M (5 s) repetition-draw
playouts, mostly in positions 10–12.
- So the per-edge draw counts of 3.5 will get real use.
### Cross-check against the ValueHash comment (37–85 %)
The comment in `mcts.h` says 37–85 % of leaf evaluations in a 5-second search
repeat a position already evaluated. Measured `leaf_tt` over all positions:
- 60.1 % at 1000 ms;
- 60.7 % at 5000 ms;
- 53.6 % at Hash 16;
- 66.0 % without GC.
All four are inside the range. Per position the spread is wider, 15–98 %:
- Low: the open middlegames 2 and 8, at 15–26 %.
- High: the pawn endgames 11 and 12 and the rook endgame 15, at 89–98 %.
The comment does not say which positions it measured, so a wider spread per
position is plausible. `vh_hits` stays within a few points of `leaf_tt` in every
row, which is consistent with the counters being right.
### Edges per node for the arena split (step 2)
| measurement | `r_tree` (edges per visited node) | `r_graph` (per distinct key) |
| --- | ---: | ---: |
| 5000 ms, Hash 1024, no GC (growth ratio) | **13.0** (per position 3.6–21.0; middlegames 18.9–21.0, endgames 11/12/15 3.6–5.5) | 18.1 |
| 5000 ms, Hash 64, end of search after 153 GCs | 5.0 (2.6–12.3) | 7.4 |
| 1000 ms, Hash 64 (14 GCs) | 9.5 | 14.0 |
| 5000 ms, Hash 16 (764 GCs) | 3.1 | 4.3 |
- With 16 B edges and 32 B nodes, the edge-to-node arena byte ratio is `r/2`:
6.5 at r = 13, about 10 for middlegames at r ≈ 20.
- GC keeps pruned nodes and drops their edges, so `r` right after a collection
is far below the ratio at which the arenas fill between collections.
- The no-GC figure decides which arena fills first. Step 2 should size for it,
or for the middlegame value, and check that the 5000 ms Hash 64 runs do not
hit GC on the node arena first.