plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
06284d5
— Peter John
2026-11-09T21:21:05+05:30
Benchmarks: Orb Run restarts like master's, and master must print what the branch prints
benchmarks/master_vs_simpler/run.py
CHANGED
|
@@ -17,13 +17,15 @@ data and print the same checksum. The two games are drivers written around each
|
|
|
17
17
|
own game (master's examples/games/orbitrunner and balloonpop, the branch's
|
|
18
18
|
examples/games/orb_run and kids/balloon_pop): this script copies the game without its
|
|
19
19
|
`main` and tests and appends a headless `main` that steps it a fixed number of ticks with
|
|
20
|
-
inputs that are a function of the seed and tick only.
|
|
20
|
+
inputs that are a function of the seed and tick only. The branch's Orb Run is given
|
|
21
|
+
master's restart rule (`ORB_BRANCH_AGAIN`), so the two play the same games.
|
|
21
22
|
|
|
22
23
|
For each program: `plum compile` --runs times on each branch (median ms, wasm bytes),
|
|
23
24
|
`plum build` executables (master; the branch's default, --no-fbip and --no-fusion), then
|
|
24
25
|
--runs rounds, each running every executable once as a fresh process in a rotated order.
|
|
25
26
|
Every program prints `ms <in-program ms, from io.nowMicros> checksum ...`; the run fails if
|
|
26
|
-
the branch's three builds disagree on the rest of the line
|
|
27
|
+
the branch's three builds disagree on the rest of the line, or if master's line differs from
|
|
28
|
+
the branch's.
|
|
27
29
|
"""
|
|
28
30
|
import argparse
|
|
29
31
|
import json
|
|
@@ -169,6 +171,16 @@ fun main(io: Io) =
|
|
|
169
171
|
io.printLn("ms {el} checksum {tally.check} overs {tally.overs} scoreAtOver {tally.scores} minesAtEnd {tally.mines}")
|
|
170
172
|
'''
|
|
171
173
|
|
|
174
|
+
# Master's restart keeps the world's random stream (`World.restart` places the orbs, then
|
|
175
|
+
# the mines, from where the stream is); the branch's `Again` seeds a new run with the
|
|
176
|
+
# stream's next Int. Both games place a fresh run the same way (three orbs, then three
|
|
177
|
+
# mines, around the middle), so the branch's game is given master's rule: its next run
|
|
178
|
+
# goes on from the stream (`Random.seeded(rng.seed)` is `rng`). Without this the two runs
|
|
179
|
+
# differ after the first game over (seed 13 at tick 2100, seen at 2695 as a hit).
|
|
180
|
+
ORB_BRANCH_AGAIN = (
|
|
181
|
+
"Again => if self.over then self.run(self.rng.nextInt().value, self.best.max(self.score)) else self",
|
|
182
|
+
"Again => if self.over then self.run(self.rng.seed, self.best.max(self.score)) else self")
|
|
183
|
+
|
|
172
184
|
BP_MASTER = '''
|
|
173
185
|
fun main(io: Io)
|
|
174
186
|
t0 := io.nowMicros()
|
|
@@ -225,7 +237,11 @@ def write_games(master, out):
|
|
|
225
237
|
mp, bp = f"{out}/{name}_master.plum", f"{out}/{name}_branch.plum"
|
|
226
238
|
for path, src, sig, drv in ((mp, msrc, msig, mdrv), (bp, bsrc, bsig, bdrv)):
|
|
227
239
|
body = drv.replace("SEEDS", seeds).replace("TICKS", str(ticks))
|
|
240
|
+
game = strip_main(src, sig)
|
|
241
|
+
if path == bp and name == "orb_run":
|
|
242
|
+
assert ORB_BRANCH_AGAIN[0] in game, "orb_run's Again changed: update ORB_BRANCH_AGAIN"
|
|
243
|
+
game = game.replace(*ORB_BRANCH_AGAIN)
|
|
228
|
-
open(path, "w").write(
|
|
244
|
+
open(path, "w").write(game + body)
|
|
229
245
|
progs.append((name, mp, bp))
|
|
230
246
|
return progs
|
|
231
247
|
|
|
@@ -283,6 +299,8 @@ def main():
|
|
|
283
299
|
lines = {v: sorted(r["line"][v]) for v in names}
|
|
284
300
|
if len({tuple(lines[v]) for v in names[1:]}) != 1 or len(lines["branch"]) != 1:
|
|
285
301
|
sys.exit(f"{name}: the branch's builds disagree: {lines}")
|
|
302
|
+
if lines["master"] != lines["branch"]:
|
|
303
|
+
sys.exit(f"{name}: master and the branch print different results: {lines}")
|
|
286
304
|
r["line"] = lines
|
|
287
305
|
json.dump(res, open(f"{out}/results.json", "w"), indent=1)
|
|
288
306
|
med = statistics.median
|
docs/benchmarks/2026-11-09-master-vs-simpler-language.md
CHANGED
|
@@ -6,7 +6,7 @@ Taken 2026-11-09 on an Apple M3 Pro (18 GB), macOS 26.6.2. Master at `cd59829` (
|
|
|
6
6
|
|
|
7
7
|
## Short answer
|
|
8
8
|
|
|
9
|
-
- **Same source on both: none.** No program compiles unchanged on both branches, so every number here is from a port (see [Method](#method)). The ports print the same checksums on both
|
|
9
|
+
- **Same source on both: none.** No program compiles unchanged on both branches, so every number here is from a port (see [Method](#method)). The ports print the same checksums on both. Orb Run does so only once the branch's game is given master's restart rule (see [the games](#games-headless-ported-drivers)).
|
|
10
10
|
- **The compiler is much slower on the branch for real programs.** Compiling a game takes 5 times as long (3.3 s against 0.65 s for Orb Run, 2.4 s against 0.48 s for Balloon Pop), and the wasm is twice as big. On small programs it's 3 to 40% slower, with a fixed 5 KB more wasm.
|
|
11
11
|
- **The branch's games run slower.** A headless tick costs 1.4 times as much in Orb Run and 3.1 times as much in Balloon Pop.
|
|
12
12
|
- **The branch's persistent scene tree is the fastest tree on most workloads.** It beats master's persistent tree (`game_enum_tree`) by 2 to 3 times, and master's mutable trees on everything except step (17% slower than `std/game`) and eager transforms (2% slower).
|
|
@@ -77,7 +77,7 @@ The N = 100 rows are left out: they're all under 15 ms, at the branch's clock re
|
|
|
77
77
|
| Orb Run | 13 seeds × 3000 | 424 (422-429) | 603 (599-604) | 600 (599-602) | 600 (599-603) | **1.42x** | 10.9 / 15.5 µs |
|
|
78
78
|
| Balloon Pop | 6 seeds × 20000 | 151 (150-156) | 472 (470-473) | 473 (468-474) | 474 (474-476) | **3.13x** | 1.26 / 3.93 µs |
|
|
79
79
|
|
|
80
|
-
- **Orb Run**: steering keys from a hash of (seed, tick), a pointer move every tick, and Enter every 150 ticks while the game is over. Master's driver starts on the play scene (`OrbitRunner.headless`). The branch's driver presses Enter once on the title screen, before the timed ticks. Both play 5 games to game over with the same scores, and end with 40 mines. The
|
|
80
|
+
- **Orb Run**: steering keys from a hash of (seed, tick), a pointer move every tick, and Enter every 150 ticks while the game is over. Master's driver starts on the play scene (`OrbitRunner.headless`). The branch's driver presses Enter once on the title screen, before the timed ticks. Both play 5 games to game over with the same scores, and end with 40 mines. The two games restart differently: master's `World.restart` places the orbs and mines from where the random stream is, and the branch's `Again` seeds the new run with the stream's next Int. The driver therefore gives the branch's game master's rule (`ORB_BRANCH_AGAIN` in `run.py`). Without it, seed 13 diverged at tick 2100, its first restart, and the difference showed at tick 2695, when a mine hit the ship on the branch only. With it, all 13 seeds match bit for bit on every tick: the ship, every orb and every mine (position and velocity), the random state, score, lives and game over. The one exception is cosmetic: while the game is over, the branch zeroes the orbs' and mines' velocities and master keeps them but doesn't move them. The checksum is the same on master and on the branch's default, `--no-fbip` and `--no-fusion` builds. The numbers in this report were measured before this change. The run times shouldn't move, because only the restarted runs differ.
|
|
81
81
|
- **Balloon Pop**: a `PointerDown` at ((97t) mod 800, (61t) mod 600) every tick, on an 800 by 600 screen. Both print the same checksum and 3975 pops. The two games are the same rules from the same random numbers.
|
|
82
82
|
|
|
83
83
|
## Compile time and wasm size
|