plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
87a57d1
— Peter John
2026-11-11T08:03:43+05:30
docs/benchmarks: rerun simpler-language before and after at 5d384800, under low load
docs/benchmarks/2026-11-11-simpler-language-before-after.md
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
# simpler-language before and after 2026-11-10: compile time, wasm size and run time
|
|
2
2
|
|
|
3
|
-
Taken 2026-11-11 on an Apple M3 Pro (11 cores, 18 GB), macOS 26.6.2. "Before" is simpler-language at `3cd4692f` (2026-11-10 09:27, the morning of 2026-11-10), "after" is its tip at `
|
|
3
|
+
Taken 2026-11-11 on an Apple M3 Pro (11 cores, 18 GB), macOS 26.6.2. "Before" is simpler-language at `3cd4692f` (2026-11-10 09:27, the morning of 2026-11-10), "after" is its tip at `5d384800` (2026-11-11 07:26), 171 commits later. Both compilers were built with `cargo build --release -p plum-cli`, each in its own worktree. Master is not involved.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This is the second run of this comparison. The first, against `7c82a31f` (2026-11-11 01:26), was taken under a load average of 5 to 19. Since then two code changes landed: `95a32e52` (uniqueness: reuse matched cells in generic fns and methods, so a uniquely owned `Map` is updated in place) and `7152cc21` (native `Int`, `Byte`, `Bool` and `Float` compare, copied into their callers). The other five commits in `7c82a31f..5d384800` are docs and a merge. See [Changed since the first run](#changed-since-the-first-run).
|
|
6
|
+
|
|
7
|
+
**Load.** The run waited until the 1-minute load average was at or below 3. It was 2.1 at the start of the compile timings, 2.1 for the wasm sizes, 7.9 at the start of the game runs (falling to 6.2; part of it was the builds just before, and another session's `target/debug/plum` was running at about 110% CPU), 6.6 at the start of the micro workloads (falling to 2.9), 2.6 for the scene trees (falling to 1.6), 1.6 for `map_snapshots` and `static_calls`, and 1.9 at the start of the test suite (6.7 at its end; the suite itself uses every core). The before and after runs were alternated, round by round, so both saw the same load, and the ranges are tight. Treat ratios within about 5% as noise. Compile time is given as process CPU time (user plus sys), which the load affects less.
|
|
6
8
|
|
|
7
9
|
## Short answer
|
|
8
10
|
|
|
9
|
-
- **Compiling got slower.** CPU time is 1.
|
|
10
|
-
- **The wasm got smaller.** It is 7 to 11% smaller for the games and the scene tree, and 56 to 64% smaller for the small examples. The
|
|
11
|
-
- **The games got faster.** A headless tick of Orb Run went from 5.
|
|
12
|
-
- **The micro workloads are faster or level, except `map`.** `map` is
|
|
13
|
-
- **The scene tree is
|
|
14
|
-
- **The test suite takes longer**:
|
|
15
|
-
- **`--no-fbip` and `--no-fusion`
|
|
11
|
+
- **Compiling got slower.** CPU time is 1.35x for Orb Run (519 ms to 699 ms), 1.46x for Balloon Pop, 1.68x for the scene-tree program, and 1.8x to 1.9x for the small examples (basics: 51 ms to 97 ms). In wall time the gap is smaller (Orb Run: 521 ms to 603 ms, 1.16x), because the loader now parses on several threads. With `PLUM_THREADS=1` the after compiler uses less CPU and more wall time: Orb Run takes 633 ms of CPU (1.22x before) and 635 ms of wall, basics 77 ms (1.51x). So the threads cost Orb Run 66 ms of CPU to save 32 ms of wall; the rest of the extra CPU is real work. The same programs reach 17 to 25% more std items, and every pass that walks the program got slower by about that much.
|
|
12
|
+
- **The wasm got smaller.** It is 7 to 11% smaller for the games and the scene tree, and 56 to 64% smaller for the small examples. The post-pass does all of this and more: with `PLUM_NO_WASM_OPT=1` the after wasm is 17 to 19% bigger than before for the games (1.3x to 1.9x for the smaller programs). The web build's `plum.wasm` shrank from 99,308 to 77,914 bytes for Orb Run (0.78x) and from 79,714 to 63,296 for Balloon Pop (0.79x).
|
|
13
|
+
- **The games got faster.** A headless tick of Orb Run went from 5.24 µs to 2.27 µs (0.43x), and Balloon Pop from 1.69 µs to 1.17 µs (0.69x). Both trees print the expected checksums: Orb Run 871028980 and Balloon Pop 234038249 with 3975 pops, on all three builds.
|
|
14
|
+
- **The micro workloads are faster or level, except `map`.** `map` is 1.70x slower (166 ms to 282 ms), down from 3.9x in the first run: Map is now a persistent tree, not a hash table, but its insert reuses the cells it owns. `trig` is 0.55x, a different algorithm too (fdlibm ports, not short series). On the same algorithm, `array` is 0.59x, `str` 0.81x and `particles` 0.84x. `fib`, `loop`, `cons` and `cons_rec` are level.
|
|
15
|
+
- **The scene tree is 3 to 28% faster on every workload**, the same ratios as in the first run. The biggest gains are on churn (0.72x to 0.76x) and step (0.75x to 0.76x). The checksums agree with before on every cell.
|
|
16
|
+
- **The test suite takes longer**: 47.2 s to 76.8 s of CPU (1.63x) and 5.3 s to 9.2 s of wall. It also has more tests: 1260 tests in 250 files before, 1391 in 281 after. CPU per test is 37 ms against 55 ms (1.47x).
|
|
17
|
+
- **`--no-fbip` and `--no-fusion` change two things.** The `cons` pipeline without fusion takes about 965 ms in both trees, against 138 ms with it. And `map` in the after tree takes 282 ms by default, 419 ms with `--no-fbip` and 421 ms with `--no-fusion`: the cell reuse is what the flags turn off. Nothing else moves.
|
|
16
18
|
|
|
17
19
|
## Method
|
|
18
20
|
|
|
@@ -21,9 +23,9 @@ Taken 2026-11-11 on an Apple M3 Pro (11 cores, 18 GB), macOS 26.6.2. "Before" is
|
|
|
21
23
|
**Harness.** A scratch script (not committed) does the following:
|
|
22
24
|
|
|
23
25
|
- It runs each tree's own compiler from that tree's root, so each gets its own std.
|
|
24
|
-
- It times `plum compile` with `
|
|
25
|
-
- It writes the game drivers the way each tree's `benchmarks/master_vs_simpler/run.py` does: it imports that file and uses its own `ORB_BRANCH`, `BP_BRANCH`, `strip_main` and `ORB_BRANCH_AGAIN`. The before tree's
|
|
26
|
-
- It builds every runtime program with `plum build` (default, `--no-fbip` and `--no-fusion`), then runs every executable once per round, in a rotated order that alternates before and after, for 5 rounds. Each program prints its own time from `io.nowMicros()`.
|
|
26
|
+
- It times `plum compile` with `wait4` on the child process (user plus sys CPU, plus wall time), 5 rounds, with the order flipped every round. Each round compiles with the before compiler, the after compiler, and the after compiler with `PLUM_THREADS=1`.
|
|
27
|
+
- It writes the game drivers the way each tree's `benchmarks/master_vs_simpler/run.py` does: it imports that file and uses its own `ORB_BRANCH`, `BP_BRANCH`, `strip_main` and `ORB_BRANCH_AGAIN`. The before tree's `write_games` requires a master checkout, so the harness splices the branch side itself.
|
|
28
|
+
- It builds every runtime program with `plum build` (default, `--no-fbip` and `--no-fusion`), then runs every executable once per round, in a rotated order that alternates before and after, for 5 rounds. Each program prints its own time from `io.nowMicros()`; `wait4` gives the process CPU.
|
|
27
29
|
- The scene-tree program takes the workload and N as arguments in the after tree. In the before tree it reads them from `scene_trees.args`; the harness writes that file before each before run.
|
|
28
30
|
|
|
29
31
|
Every number is the median of 5, with the range in brackets. The test suite ran once per tree.
|
|
@@ -32,34 +34,36 @@ Every number is the median of 5, with the range in brackets. The test suite ran
|
|
|
32
34
|
|
|
33
35
|
## Compile time
|
|
34
36
|
|
|
35
|
-
`plum compile`, median of 5. CPU ms is user plus sys.
|
|
37
|
+
`plum compile`, median of 5. CPU ms is user plus sys.
|
|
38
|
+
|
|
39
|
+
| program | before CPU ms | after CPU ms | after / before | after CPU ms, `PLUM_THREADS=1` | before wall ms | after wall ms | after wall ms, `PLUM_THREADS=1` |
|
|
40
|
+
|---|---|---|---|---|---|---|---|
|
|
41
|
+
| Orb Run | 519 (518-527) | 699 (695-704) | **1.35x** | 633 (632-638) | 521 | 603 | 635 |
|
|
42
|
+
| Balloon Pop | 413 (411-415) | 603 (600-607) | **1.46x** | 541 (541-541) | 416 | 513 | 543 |
|
|
43
|
+
| functional | 71 (71-72) | 126 (126-127) | **1.77x** | 110 (109-111) | 73 | 101 | 112 |
|
|
44
|
+
| basics | 51 (51-51) | 97 (96-101) | **1.90x** | 77 (77-77) | 52 | 66 | 79 |
|
|
45
|
+
| scene tree | 241 (240-242) | 404 (403-409) | **1.68x** | 351 (349-355) | 243 | 327 | 353 |
|
|
36
46
|
|
|
37
|
-
|
|
38
|
-
|---|---|---|---|---|---|
|
|
39
|
-
| Orb Run | 538 (536-540) | 708 (702-717) | **1.32x** | 540 | 612 |
|
|
40
|
-
| Balloon Pop | 426 (424-426) | 596 (593-600) | **1.40x** | 428 | 503 |
|
|
41
|
-
| functional | 73 (73-74) | 123 (119-126) | **1.69x** | 75 | 93 |
|
|
42
|
-
| basics | 52 (51-52) | 103 (102-109) | **2.00x** | 53 | 69 |
|
|
43
|
-
| scene tree | 248 (247-248) | 408 (401-410) | **1.65x** | 250 | 331 |
|
|
47
|
+
With one thread, the after compiler's CPU is 1.22x before for Orb Run, 1.31x for Balloon Pop, 1.46x for the scene tree, and 1.51x to 1.55x for the small examples. The threads cost 53 to 66 ms of CPU on the games and the scene tree and 16 to 20 ms on the small examples, and save 11 to 32 ms of wall.
|
|
44
48
|
|
|
45
49
|
`PLUM_TIMINGS=1` phase table for Orb Run, median of 5 alternated runs. These are the compiler's own wall-clock times, in ms. A dash means the phase doesn't exist in that tree.
|
|
46
50
|
|
|
47
|
-
| phase | before | after | after / before |
|
|
48
|
-
|---|---|---|---|
|
|
49
|
-
| load |
|
|
50
|
-
| check |
|
|
51
|
-
| dead code (rewrite + re-check) |
|
|
52
|
-
| closure specialisation |
|
|
53
|
-
| fusion (before: includes uniqueness
|
|
54
|
-
| in place (uniqueness
|
|
55
|
-
| fusion + in place |
|
|
56
|
-
| trmc |
|
|
57
|
-
| check + passes |
|
|
58
|
-
| codegen |
|
|
59
|
-
| wasm passes | - |
|
|
60
|
-
| compile |
|
|
61
|
-
|
|
62
|
-
The checker sees 1,516 items (1,080 fns) for Orb Run before and 1,778 (1,301 fns) after, 17% more. After dead code, 870 items remain before and 1,027 after (+18%).
|
|
51
|
+
| phase | before | after | after / before | after, `PLUM_THREADS=1` |
|
|
52
|
+
|---|---|---|---|---|
|
|
53
|
+
| load | 69.5 | 63.3 | 0.91x | 97.2 |
|
|
54
|
+
| check | 111.6 | 141.9 | 1.27x | 140.6 |
|
|
55
|
+
| dead code (rewrite + re-check) | 33.8 | 40.9 | 1.21x | 41.9 |
|
|
56
|
+
| closure specialisation | 30.5 | 38.4 | 1.26x | 39.5 |
|
|
57
|
+
| fusion (before: includes uniqueness 125.9) | 216.5 | 91.0 | - | 90.1 |
|
|
58
|
+
| in place (uniqueness 106.6) | - | 142.3 | - | 141.8 |
|
|
59
|
+
| fusion + in place | 216.5 | 233.3 | 1.08x | 231.9 |
|
|
60
|
+
| trmc | 24.9 | 32.1 | 1.29x | 32.4 |
|
|
61
|
+
| check + passes | 418.9 | 488.0 | 1.16x | 488.0 |
|
|
62
|
+
| codegen | 24.7 | 29.9 | 1.21x | 29.3 |
|
|
63
|
+
| wasm passes | - | 11.1 | - | 11.1 |
|
|
64
|
+
| compile | 446.8 | 534.6 | **1.20x** | 534.4 |
|
|
65
|
+
|
|
66
|
+
The checker sees 1,516 items (1,080 fns) for Orb Run before and 1,778 (1,301 fns) after, 17% more. After dead code, 870 items remain before and 1,027 after (+18%). The re-checks after each pass add up to 86.5 ms before (4 of them) and 134.3 ms after (5, 25 to 28 ms each): a quarter of the after compile. With one thread only the load phase changes (63 ms to 97 ms of wall).
|
|
63
67
|
|
|
64
68
|
## Wasm size
|
|
65
69
|
|
|
@@ -67,46 +71,48 @@ The wasm bytes are `plum compile`'s output. "fns" counts defined functions; impo
|
|
|
67
71
|
|
|
68
72
|
| program | before bytes | after bytes | after / before | after, `PLUM_NO_WASM_OPT=1` | before fns | after fns | after fns, no post-pass |
|
|
69
73
|
|---|---|---|---|---|---|---|---|
|
|
70
|
-
| Orb Run | 99,308 |
|
|
74
|
+
| Orb Run | 99,308 | 92,444 | 0.93x | 117,873 | 979 (+30) | 701 (+30) | 1,078 |
|
|
71
|
-
| Balloon Pop | 79,714 |
|
|
75
|
+
| Balloon Pop | 79,714 | 74,418 | 0.93x | 93,355 | 734 (+24) | 533 (+24) | 818 |
|
|
72
|
-
| functional | 12,202 | 5,423 | **0.44x** | 16,
|
|
76
|
+
| functional | 12,202 | 5,423 | **0.44x** | 16,446 | 121 (+0) | 37 (+1) | 167 |
|
|
73
|
-
| basics | 4,239 | 1,526 | **0.36x** | 8,
|
|
77
|
+
| basics | 4,239 | 1,526 | **0.36x** | 8,006 | 62 (+1) | 10 (+2) | 95 |
|
|
74
|
-
| scene tree | 37,042 | 33,
|
|
78
|
+
| scene tree | 37,042 | 33,089 | 0.89x | 49,472 | 399 (+11) | 247 (+9) | 461 |
|
|
75
79
|
|
|
76
|
-
`plum build` of a game makes the web folder. The web build's `plum.wasm` is 99,308 bytes before and
|
|
80
|
+
`plum build` of a game makes the web folder. The web build's `plum.wasm` is 99,308 bytes before and 77,914 after for Orb Run (0.78x), and 79,714 before and 63,296 after for Balloon Pop (0.79x). The before web wasm is byte for byte the size of `plum compile`'s output. The after web wasm is a further 15% smaller, because it ships without the name section (`a596fb10`). The rest of the folder is the same size in both trees, including the 51,573-byte `plum_bridge.js`. Building the web folder takes 524 ms against 706 ms of CPU for Orb Run, and 415 against 605 for Balloon Pop.
|
|
77
81
|
|
|
78
|
-
Without the post-pass, the after compiler's wasm is 17 to 19% bigger than before for the games and 1.3x to 1.9x for the scene tree and the small programs. The post-pass (`46ee3ec0` unreachable functions, `07e9bb26` inlining tiny leaves, `c10b729d` redundant casts, `7ff787de` one type per signature) removes
|
|
82
|
+
Without the post-pass, the after compiler's wasm is 17 to 19% bigger than before for the games and 1.3x to 1.9x for the scene tree and the small programs. The post-pass (`46ee3ec0` unreachable functions, `07e9bb26` inlining tiny leaves, `c10b729d` redundant casts, `7ff787de` one type per signature) removes 20 to 81% of the bytes. So the size win comes from the post-pass, on top of a program that reaches more std than before.
|
|
79
83
|
|
|
80
84
|
## Games (headless drivers, update only)
|
|
81
85
|
|
|
82
|
-
Each tree's own driver, spliced
|
|
86
|
+
Each tree's own driver, spliced from its own `run.py`. Orb Run plays 13 seeds of 3,000 ticks (39,000 ticks), and Balloon Pop 6 seeds of 20,000 ticks (120,000 ticks). Times are the in-program ms, median of 5. "Process CPU" is the whole executable, startup included. The load was 6 to 8 during these runs, from the builds just before and from another session.
|
|
83
87
|
|
|
84
88
|
| game | build | before ms | after ms | after / before | before µs/tick | after µs/tick | before process CPU ms | after process CPU ms |
|
|
85
89
|
|---|---|---|---|---|---|---|---|---|
|
|
86
|
-
| Orb Run | default |
|
|
90
|
+
| Orb Run | default | 204 (204-210) | 88.5 (88.0-88.8) | **0.43x** | 5.24 | 2.27 | 425 | 94 |
|
|
87
|
-
| Orb Run | --no-fbip |
|
|
91
|
+
| Orb Run | --no-fbip | 205 (204-221) | 88.3 (87.7-88.6) | 0.43x | 5.25 | 2.26 | 422 | 93 |
|
|
88
|
-
| Orb Run | --no-fusion |
|
|
92
|
+
| Orb Run | --no-fusion | 217 (204-219) | 89.0 (88.3-89.5) | 0.41x | 5.57 | 2.28 | 437 | 94 |
|
|
89
|
-
| Balloon Pop | default |
|
|
93
|
+
| Balloon Pop | default | 203 (202-218) | 140 (140-141) | **0.69x** | 1.69 | 1.17 | 377 | 146 |
|
|
90
|
-
| Balloon Pop | --no-fbip |
|
|
94
|
+
| Balloon Pop | --no-fbip | 204 (202-209) | 140 (138-140) | 0.68x | 1.70 | 1.17 | 380 | 145 |
|
|
91
|
-
| Balloon Pop | --no-fusion |
|
|
95
|
+
| Balloon Pop | --no-fusion | 204 (204-208) | 142 (141-143) | 0.69x | 1.70 | 1.18 | 382 | 148 |
|
|
92
96
|
|
|
93
|
-
The checksums match on every build in both trees. Orb Run prints `checksum 871028980 overs 5 scoreAtOver 80 minesAtEnd 40`, and Balloon Pop `checksum 234038249 pops 3975`.
|
|
97
|
+
The checksums match on every build in both trees. Orb Run prints `checksum 871028980 overs 5 scoreAtOver 80 minesAtEnd 40`, and Balloon Pop `checksum 234038249 pops 3975`. The before Orb Run `--no-fusion` median (217) sits at the top of a wide range (204 to 219): read it as level with the default build.
|
|
94
98
|
|
|
95
99
|
## Micro workloads
|
|
96
100
|
|
|
97
101
|
`benchmarks/master_vs_simpler/branch/*.plum` from each tree, built with `plum build`. Times are the in-program ms, median of 5. Every build in both trees prints the same checksum.
|
|
98
102
|
|
|
99
|
-
| program | before | after | after / before | before --no-fbip | after --no-fbip | before --no-fusion | after --no-fusion | note |
|
|
103
|
+
| program | before | after | after / before | before --no-fbip | after --no-fbip | before --no-fusion | after --no-fusion | before / after process CPU ms | note |
|
|
100
|
-
|---|---|---|---|---|---|---|---|---|
|
|
104
|
+
|---|---|---|---|---|---|---|---|---|---|
|
|
101
|
-
| fib |
|
|
105
|
+
| fib | 153 (153-169) | 156 (155-156) | 1.02x | 155 | 156 | 158 | 160 | 187 / 159 | |
|
|
102
|
-
| loop |
|
|
106
|
+
| loop | 298 (298-299) | 298 (298-298) | 1.00x | 298 | 298 | 298 | 298 | 328 / 301 | |
|
|
103
|
-
| array |
|
|
107
|
+
| array | 105 (105-107) | 62 (62-67) | **0.59x** | 106 | 63 | 106 | 63 | 141 / 66 | reads with `at`, which is now checked |
|
|
104
|
-
| map |
|
|
108
|
+
| map | 166 (165-179) | 282 (281-308) | **1.70x** | 166 | 419 | 165 | 421 | 205 / 285 | different algorithm: hash table before, persistent weight-balanced tree after |
|
|
105
|
-
| cons |
|
|
109
|
+
| cons | 138 (137-143) | 138 (137-163) | 1.00x | 140 | 138 | 966 | 964 | 172 / 142 | |
|
|
106
|
-
| cons_rec | 1,
|
|
110
|
+
| cons_rec | 1,866 (1,836-1,873) | 1,852 (1,829-1,879) | 0.99x | 1,837 | 1,835 | 1,838 | 1,826 | 1,904 / 1,857 | |
|
|
107
|
-
| str |
|
|
111
|
+
| str | 728 (723-751) | 588 (586-594) | **0.81x** | 737 | 595 | 734 | 589 | 760 / 592 | |
|
|
108
|
-
| particles |
|
|
112
|
+
| particles | 205 (204-232) | 172 (172-186) | **0.84x** | 205 | 172 | 204 | 172 | 246 / 175 | |
|
|
109
|
-
| trig |
|
|
113
|
+
| trig | 85 (85-103) | 47 (47-71) | 0.55x | 85 | 47 | 85 | 47 | 117 / 50 | different algorithm: short series before, fdlibm ports after |
|
|
114
|
+
|
|
115
|
+
The process CPU of a before executable is 25 to 75 ms above its in-program time and the after one's 3 to 5 ms: the after executables start from a precompiled module (`d3dabfb0`).
|
|
110
116
|
|
|
111
117
|
## Scene tree
|
|
112
118
|
|
|
@@ -114,95 +120,115 @@ Each tree's `benchmarks/scene_trees/scene_tree.plum`, default build only. Times
|
|
|
114
120
|
|
|
115
121
|
| workload | N | before | after | after / before |
|
|
116
122
|
|---|---|---|---|---|
|
|
117
|
-
| step | 1000 |
|
|
123
|
+
| step | 1000 | 22 (21-30) | 16 (16-35) | 0.75x |
|
|
118
|
-
| step | 10000 |
|
|
124
|
+
| step | 10000 | 191 (191-192) | 146 (144-148) | **0.76x** |
|
|
119
|
-
| churn | 1000 |
|
|
125
|
+
| churn | 1000 | 40 (40-40) | 30 (29-30) | 0.74x |
|
|
120
|
-
| churn | 10000 |
|
|
126
|
+
| churn | 10000 | 369 (368-370) | 266 (265-270) | **0.72x** |
|
|
121
|
-
| draw | 1000 |
|
|
127
|
+
| draw | 1000 | 30 (29-31) | 26 (26-26) | 0.87x |
|
|
122
|
-
| draw | 10000 |
|
|
128
|
+
| draw | 10000 | 281 (280-284) | 246 (244-248) | 0.87x |
|
|
123
|
-
| hit | 1000 |
|
|
129
|
+
| hit | 1000 | 22 (22-23) | 18 (18-19) | 0.83x |
|
|
124
|
-
| hit | 10000 |
|
|
130
|
+
| hit | 10000 | 192 (190-194) | 177 (176-179) | 0.92x |
|
|
125
|
-
| step, no transforms | 1000 |
|
|
131
|
+
| step, no transforms | 1000 | 17 (17-18) | 14 (14-15) | 0.85x |
|
|
126
|
-
| step, no transforms | 10000 |
|
|
132
|
+
| step, no transforms | 10000 | 152 (151-153) | 130 (130-132) | 0.86x |
|
|
127
|
-
| step, eager transforms | 1000 |
|
|
133
|
+
| step, eager transforms | 1000 | 47 (46-47) | 41 (40-41) | 0.87x |
|
|
128
|
-
| step, eager transforms | 10000 |
|
|
134
|
+
| step, eager transforms | 10000 | 439 (436-444) | 388 (385-393) | 0.88x |
|
|
129
|
-
| churn, apply after | 1000 |
|
|
135
|
+
| churn, apply after | 1000 | 44 (44-44) | 33 (33-34) | 0.75x |
|
|
130
|
-
| churn, apply after | 10000 |
|
|
136
|
+
| churn, apply after | 10000 | 409 (408-409) | 306 (305-308) | 0.75x |
|
|
131
|
-
| step, 60 kept | 1000 |
|
|
137
|
+
| step, 60 kept | 1000 | 26 (25-27) | 21 (20-21) | 0.80x |
|
|
132
|
-
| step, 60 kept | 10000 | 1,
|
|
138
|
+
| step, 60 kept | 10000 | 1,621 (1,612-1,763) | 1,575 (1,573-1,603) | 0.97x |
|
|
133
|
-
| churn, 60 kept | 1000 |
|
|
139
|
+
| churn, 60 kept | 1000 | 44 (44-48) | 33 (33-48) | 0.76x |
|
|
134
|
-
| churn, 60 kept | 10000 | 1,
|
|
140
|
+
| churn, 60 kept | 10000 | 1,826 (1,796-1,972) | 1,729 (1,703-1,754) | 0.95x |
|
|
135
|
-
| mostly still | 1000 |
|
|
141
|
+
| mostly still | 1000 | 15 (15-15) | 12 (12-13) | 0.82x |
|
|
136
|
-
| mostly still | 10000 |
|
|
142
|
+
| mostly still | 10000 | 134 (133-134) | 111 (110-111) | 0.83x |
|
|
137
|
-
| mostly still, one group | 1000 |
|
|
143
|
+
| mostly still, one group | 1000 | 15 (15-16) | 12 (12-13) | 0.82x |
|
|
138
|
-
| mostly still, one group | 10000 |
|
|
144
|
+
| mostly still, one group | 10000 | 133 (132-133) | 108 (108-108) | 0.81x |
|
|
139
145
|
|
|
140
146
|
## Test suite
|
|
141
147
|
|
|
142
|
-
`target/release/plum test std examples tests`, once per tree. Each tree runs its own tests, and every test passed in both.
|
|
148
|
+
`target/release/plum test std examples tests`, once per tree, before first. Each tree runs its own tests, and every test passed in both. Another session's `target/debug/plum` was using about one core during the after run, so its wall time is the less reliable number.
|
|
143
149
|
|
|
144
150
|
| | before | after | after / before |
|
|
145
151
|
|---|---|---|---|
|
|
146
|
-
| wall s |
|
|
147
|
-
| CPU s (user + sys, all workers) |
|
|
148
|
-
| tests (files) | 1,260 (250) | 1,
|
|
149
|
-
| CPU ms per test | 37 |
|
|
152
|
+
| wall s | 5.3 | 9.2 | 1.73x |
|
|
153
|
+
| CPU s (user + sys, all workers) | 47.2 | 76.8 | **1.63x** |
|
|
154
|
+
| tests (files) | 1,260 (250) | 1,391 (281) | 1.10x (1.12x) |
|
|
155
|
+
| CPU ms per test | 37 | 55 | 1.47x |
|
|
156
|
+
|
|
157
|
+
## Two more after-tree benchmarks
|
|
158
|
+
|
|
159
|
+
Only the after tree has these. Median of 5, alternated.
|
|
160
|
+
|
|
161
|
+
- **`benchmarks/map_snapshots`** (100 rounds of 1,000 updates to a 100,000-entry Map, keeping every snapshot, then reading them): 329 ms in the program (326-354) and 333 ms of process CPU by default, 328 ms (325-330) with `--no-fbip`. Same checksum (978817449, 100 snapshots). Every snapshot is kept, so no cell is uniquely owned and the cell reuse has nothing to reuse: the two builds are level, as they should be.
|
|
162
|
+
- **`benchmarks/static_calls`** (20,000,000 calls of an 18-step loop): `static` takes 778 ms of process CPU (775-810), `free` 561 ms (561-561), 1.39x. Same result on both. A static method with a self tail call and a small static helper is still 39% slower than the same two functions at module level.
|
|
163
|
+
|
|
164
|
+
## Changed since the first run
|
|
165
|
+
|
|
166
|
+
The first run measured `7c82a31f` under a load of 5 to 19; this one measured `5d384800` under a load mostly at or below 3 (6 to 8 for the games). The before tree is the same commit in both runs, so its change between the runs is the load: it is 3 to 16% faster this time (Orb Run tick 5.42 µs to 5.24 µs, `map` 198 ms to 166 ms, scene-tree churn at N = 10000 389 ms to 369 ms). Most after-tree changes are the same size and come from the load too. These differ by more than that:
|
|
167
|
+
|
|
168
|
+
- **`map`: 781 ms to 282 ms (0.36x), and 3.94x before to 1.70x.** Two commits did this: `95a32e52` (the insert reuses the cells of a Map it owns) and `7152cc21` (a native `Int.compare` copied into its callers; every insert and lookup compares keys). The default build's time is steady: 282 to 310 ms in every run this morning. The `--no-fbip` build, which has no reuse, is not: 419 ms in the measured run, 476 ms in a run ten minutes later and 670 ms a few minutes after that, with the same executable, while the machine ran short of free memory (1.8 GB of swap in use, another session's test binary at 1.7 GB). So the split between the two commits isn't measured. What is measured: with the same executable, reuse makes `map` 1.5x to 2.2x faster, and the first run's `--no-fbip` time (770 ms) is in the range of this morning's. `--no-fusion` now also loses the reuse (421 ms); in the first run it didn't matter (773 ms), because there was no reuse to lose.
|
|
169
|
+
- **Wasm size: Orb Run 91,885 to 92,444 bytes (+0.6%) with 735 to 701 functions; Balloon Pop 73,476 to 74,418 (+1.3%) with 559 to 533 functions; the web builds +1.1 to 1.3 KB.** Fewer functions and slightly more bytes is what copying the native compare into each caller would do (`7152cc21` changed the wasm post-pass), but the two commits weren't measured apart. The other programs moved by under 1%.
|
|
170
|
+
- **Compile time** moved within a few percent (Orb Run 708 ms to 699 ms of CPU, basics 103 ms to 97 ms); the before tree moved by the same amount, so this is the load. The new numbers here are the `PLUM_THREADS=1` column, which wasn't measured in the first run.
|
|
171
|
+
- **The test suite** has 11 more tests in 8 more files (`tests/fbip/map_persistence/*`, `tests/std/native_compare.plum`) and uses 5.4 s more CPU (71.4 s to 76.8 s), 55 ms per test against 52. Its wall time went from 7.6 s to 9.2 s; another session was running during it, so that number is not comparable.
|
|
172
|
+
- **The scene tree** ratios are the same within 2% on every cell. The churn workloads fold a Map; they didn't gain from the Map changes in a measurable way (churn at N = 10000: 0.72x in both runs).
|
|
173
|
+
- **The games**: Orb Run 0.44x to 0.43x, Balloon Pop 0.69x in both. No change beyond the load.
|
|
150
174
|
|
|
151
175
|
## What stands out
|
|
152
176
|
|
|
153
177
|
Measured:
|
|
154
178
|
|
|
155
|
-
1. **Compile time is the one broad regression.** It is 1.
|
|
156
|
-
2. **
|
|
157
|
-
3. **The
|
|
158
|
-
4. **
|
|
159
|
-
5. **
|
|
160
|
-
6. **
|
|
161
|
-
7. **
|
|
179
|
+
1. **Compile time is the one broad regression.** It is 1.35x to 1.9x the CPU time on every program measured, and the test suite's CPU per test is 1.47x. About a third of the extra CPU on the games (66 of 180 ms for Orb Run) is the loader's threads, which buy back 32 ms of wall. Without them the after compiler still uses 1.22x (Orb Run) to 1.55x (functional) the CPU. The phase table puts the rest in the passes that walk the whole program: check (1.27x), dead code (1.21x), closure specialisation (1.26x), trmc (1.29x) and codegen (1.21x). Each grows by about as much as the item count (+17% for Orb Run). The re-checks are 134 ms of the 535 ms compile, one more than before (5 against 4). Moving the in-place updates out of fusion into their own pass didn't make that work cheaper: fusion plus in place is 233 ms against 217 ms.
|
|
180
|
+
2. **The games tick 1.4x to 2.3x faster, with no change from `--no-fbip` or `--no-fusion`.** The executables also start much more cheaply: before, Orb Run's process used 425 ms of CPU for 204 ms of work; after, 94 ms for 89 ms.
|
|
181
|
+
3. **The persistent Map costs 1.70x the hash table** on 200,000 inserts and lookups: about 280 ns per insert plus lookup, against about 165 ns. Reuse brings it from 419 ms to 282 ms (the `--no-fbip` time moved up to 670 ms in later runs, see above), and needs fusion to be on as well as FBIP.
|
|
182
|
+
4. **Checked `Slice.at` didn't make `array` slower.** It got faster (0.59x).
|
|
183
|
+
5. **Hand-written recursion with closure arguments didn't change.** `cons_rec` takes 1.85 s, against 138 ms for the same pipeline through the std with fusion, and 964 ms through the std without fusion. `fib` and `loop` are level too.
|
|
184
|
+
6. **On the scene tree, "60 kept" at N = 10000 is 10.8x plain step** (1,575 ms against 146 ms), while at N = 1000 it is 1.3x. It gained least from the two days (0.95x to 0.97x).
|
|
185
|
+
7. **A static method is 1.39x the same code as free functions** (`static_calls`, 778 against 561 ms of CPU).
|
|
162
186
|
|
|
163
187
|
Guesses, not measured:
|
|
164
188
|
|
|
165
|
-
- The extra std items come from the larger std (Decimal formatting and parsing, fdlibm math, Map's longer API, `compare` and `eq` everywhere), reached through interpolation and `toStr`.
|
|
166
|
-
- The game speed-up most likely comes from `8461d00e` (pointer routing finds the hit first, cheaper idle ticks), the codegen inlining and cast removal (`07e9bb26`, `c10b729d`), and `4c05ed80` (in-place updates on generic types).
|
|
167
|
-
- The "60 kept" gap at N = 10000 looks like garbage collector pressure from live snapshots rather than tree work, since the same tree without snapshots costs
|
|
189
|
+
- The extra std items come from the larger std (Decimal formatting and parsing, fdlibm math, Map's longer API, `compare` and `eq` everywhere), reached through interpolation and `toStr`.
|
|
190
|
+
- The game speed-up most likely comes from `8461d00e` (pointer routing finds the hit first, cheaper idle ticks), the codegen inlining and cast removal (`07e9bb26`, `c10b729d`), and `4c05ed80` (in-place updates on generic types).
|
|
191
|
+
- The "60 kept" gap at N = 10000 looks like garbage collector pressure from live snapshots rather than tree work, since the same tree without snapshots costs 146 ms.
|
|
192
|
+
- The `static_calls` gap is likely the small static `digit` not being inlined where a free function of that size is (the file's own comment names it as the suspect).
|
|
168
193
|
|
|
169
194
|
## Where performance work would pay off next
|
|
170
195
|
|
|
171
196
|
Ranked by what these numbers show:
|
|
172
197
|
|
|
173
|
-
1. **Compile time**
|
|
174
|
-
2. **
|
|
175
|
-
3. **
|
|
176
|
-
4. **The scene tree's structure with kept snapshots.** "60 kept" at N = 10000 costs
|
|
198
|
+
1. **Compile time.** Still the largest regression measured, and the test suite pays it on every file (55 ms of CPU per test). Measured: the threads explain 62 to 66 ms of the extra CPU per game; the re-checks are 25% of the compile; the whole-program passes grow with the item count. Guessed ways to win it back: prune the std before checking, check each std item once and reuse it across programs and tests, do fewer re-checks, and give the loader's threads less to do (or fewer threads) where the program is small.
|
|
199
|
+
2. **Typed closure calls.** `cons_rec` (1.85 s) and `cons` without fusion (964 ms) are closure-heavy and haven't moved, while fusion, which removes the closure calls, makes the same work 7 to 13x faster. This is indirect evidence; no profile was taken.
|
|
200
|
+
3. **Map.** Down from 3.9x to 1.7x the hash table. What is left (282 against 166 ms) is measured; where it goes (tree rebalancing, allocation, the lookups) isn't. Reuse also stops when fusion is off, which wasn't explained.
|
|
201
|
+
4. **The scene tree's structure with kept snapshots.** "60 kept" at N = 10000 costs 10.8 times a plain step. Sharing more structure between snapshots, or allocating less per step, would show up there.
|
|
202
|
+
5. **Static calls.** 1.39x free functions on `static_calls`. This is now measured, but only on that one benchmark; none of the games or micro workloads separates the two.
|
|
177
203
|
|
|
178
204
|
No evidence either way from these runs:
|
|
179
205
|
|
|
180
206
|
- unboxed enum payloads
|
|
181
207
|
- allocation-free Option and `for` loops
|
|
182
|
-
- statics slower than free functions (none of these programs separates the two)
|
|
183
208
|
|
|
184
|
-
Unchecked reads in `for` over a Slice also have no evidence for them: checked `at` showed no cost in `array`, which got faster. The games' remaining 1.2 to 2.
|
|
209
|
+
Unchecked reads in `for` over a Slice also have no evidence for them: checked `at` showed no cost in `array`, which got faster. The games' remaining 1.2 to 2.3 µs per tick wasn't profiled, so it doesn't point to any one item.
|
|
185
210
|
|
|
186
211
|
## Caveats
|
|
187
212
|
|
|
188
|
-
- The
|
|
213
|
+
- The games and the start of the micro workloads ran at a load of 6 to 8. The in-program times are wall clock; the alternation and the tight ranges limit the damage.
|
|
189
214
|
- `map` and `trig` compare different algorithms in the two trees, and `map.plum` changed shape (a `for` loop over `set` became a tail call over `with`).
|
|
190
215
|
- The before scene-tree program times itself in whole ms.
|
|
191
|
-
- Each tree's test suite is a different set of tests.
|
|
216
|
+
- Each tree's test suite is a different set of tests, and the after run shared the machine with another session.
|
|
192
217
|
- The phase table's times are the compiler's own wall-clock times. CPU per phase wasn't measured.
|
|
193
218
|
- Function counts stop at the first non-function import, which is fine for these modules: their function imports come first.
|
|
194
219
|
|
|
195
220
|
## How to rerun
|
|
196
221
|
|
|
197
|
-
After (any simpler-language checkout at or after `
|
|
222
|
+
After (any simpler-language checkout at or after `5d384800`):
|
|
198
223
|
|
|
199
224
|
```sh
|
|
200
225
|
cargo build --release -p plum-cli
|
|
201
226
|
python3 benchmarks/master_vs_simpler/run.py # micro and games, 3 builds, 5 rounds
|
|
202
227
|
python3 benchmarks/scene_trees/run.py --plum target/release/plum --sizes 1000,10000
|
|
203
228
|
PLUM_TIMINGS=1 target/release/plum compile examples/games/orb_run.plum -o /tmp/orb.wasm
|
|
229
|
+
PLUM_THREADS=1 target/release/plum compile examples/games/orb_run.plum -o /tmp/orb.wasm
|
|
204
230
|
PLUM_NO_WASM_OPT=1 target/release/plum compile examples/games/orb_run.plum -o /tmp/orb.wasm
|
|
205
231
|
target/release/plum test std examples tests
|
|
206
232
|
```
|
|
207
233
|
|
|
208
|
-
Before (`git worktree add --detach <dir> 3cd4692f`, then `cargo build --release -p plum-cli` there): both `run.py` scripts in that tree require `--master`. For the games, take the driver text from that tree's `run.py` (`ORB_BRANCH`, `BP_BRANCH`, `strip_main`, `ORB_BRANCH_AGAIN`), splice it as `write_games` does, and build with that tree's compiler from its root. Its micro programs build as they are. Its scene-tree program reads `<workload> <N>` from `scene_trees.args` in the working folder. Alternate the before and after runs. Both trees must print the checksums above. All measurements here took about
|
|
234
|
+
Before (`git worktree add --detach <dir> 3cd4692f`, then `cargo build --release -p plum-cli` there): both `run.py` scripts in that tree require `--master`. For the games, take the driver text from that tree's `run.py` (`ORB_BRANCH`, `BP_BRANCH`, `strip_main`, `ORB_BRANCH_AGAIN`), splice it as `write_games` does, and build with that tree's compiler from its root. Its micro programs build as they are. Its scene-tree program reads `<workload> <N>` from `scene_trees.args` in the working folder. Alternate the before and after runs. Both trees must print the checksums above. All measurements here took about 10 minutes after the builds.
|