OXYGENHUB
# 039b4ccb972d oxygen / docs / benchmarks.md
5.6 KiB · Markdown · last changed Benchmarks after O10b; backlog: O10b done, O10c added 1 month ago renderedsource blame history raw
1d360c91 Andy McCall ↶ 1
# Benchmarks
2
3
The harness is `crates/oxy-core/tests/bench.rs` (spec §25). It builds a
4
repository through the library, one commit at a time, then times the
5
everyday operations against thresholds:
6
7
    OXY_BENCH_DIR=~/.cache/oxy-bench \
8
      cargo test --release -p oxy-core --test bench -- --ignored --nocapture
9
10
`OXY_BENCH_FILES` (default 10 000) and `OXY_BENCH_CHANGES` (default
11
5 000) set the size. The data lands under `OXY_BENCH_DIR`; `/tmp` is often
12
a RAM disk, which hides the cost of `fsync`, so measure on a real disk.
13
14
## 2026-09-28: first run
15
16
Machine: 8 cores, x86-64, NVMe (ext4 on LVM), release build, warm cache.
17
Files are 21 lines each in 100 directories; one change in ten appends a
18
line to `hot.txt`, the rest rewrite one ordinary file.
19
20
| Operation (10 000 files, 5 000 changes) | Time | Threshold | |
21
|---|---:|---:|---|
22
| commit: import 10 000 files | 1 031 ms | 60 000 ms | ok |
23
| commit: one file (mean of 4 999) | 3 761 ms | 250 ms | **over** |
24
| status: clean working copy (stat crawl) | 2 977 ms | 2 000 ms | **over** |
25
| status: 10 files modified | 3 062 ms | 2 000 ms | **over** |
26
| commit: 10 files | 9 089 ms | 500 ms | **over** |
27
| log: whole bookmark | 408 ms | 2 000 ms | ok |
28
| blame: hot file (500 lines) | 2 920 ms | 2 000 ms | **over** |
29
| blame: ordinary file | 2 927 ms | 1 000 ms | **over** |
30
| checkpoint | 596 ms | 10 000 ms | ok |
31
| status after checkpoint | 2 873 ms | 2 000 ms | **over** |
32
| push: everything to an empty remote | 782 ms | 60 000 ms | ok |
33
| push: up to date | 4 ms | 1 000 ms | ok |
34
| clone: everything, with checkout | 3 378 ms | 60 000 ms | ok |
35
| fsck | 7 955 ms | 60 000 ms | ok |
36
| gc | 9 489 ms | 60 000 ms | ok |
37
| status after gc | 2 829 ms | 2 000 ms | **over** |
38
39
Peak resident memory over the whole run: 1 405 MiB. The run took 5 h 14 min,
40
almost all of it building the history, because each commit costs as much
41
as a status.
42
43
Smaller runs, same machine:
44
45
| Files, changes | Mean commit | Clean status | Blame (hot) | Peak memory |
46
|---|---:|---:|---:|---:|
47
| 1 000, 200 | 90 ms | 62 ms | 62 ms | 70 MiB |
48
| 1 000, 800 | 166 ms | 130 ms | 119 ms | 118 MiB |
49
| 4 000, 200 | 343 ms | 235 ms | 239 ms | 254 MiB |
50
| 10 000, 5 000 | 3 761 ms | 2 977 ms | 2 920 ms | 1 405 MiB |
51
52
### What it shows
53
54
Sync, log, checkpoints and repository maintenance are fine. Everything
55
that snapshots the working copy (status, commit, blame of the working
56
copy's base) grows with both the number of files and the length of the
57
history. Timing the phases of one snapshot at 4 000 files and 300 changes:
58
59
| Phase | Time |
60
|---|---:|
61
| load the base state (checkpoint plus the changes since) | 75–130 ms |
62
| materialize every file of the base state | 75 ms |
63
| walk the working copy against the manifest | 50 ms |
64
| build the working-copy change | 8 ms |
65
66
A clean status should be a stat walk and nothing else. The fix is backlog
67
item O10: skip loading and materializing when every file's stat matches a
68
manifest written for the same base, make the base state lazy for the
69
callers that need it, and cache materialized snapshots per state. The
70
thresholds above stay as they are until then, so the harness reports the
71
gap rather than hiding it.
b8a03993 Andy McCall ↶ 72
73
## 2026-09-28: after O10a
74
75
`State::maximal` compared every pair of heads, and the benchmark's
76
bookmark has about 4 500 of them (changes to different files are
77
independent). It now walks once; commit also stops loading the base state
78
twice. Same machine and size:
79
80
| Operation (10 000 files, 5 000 changes) | Before | After | Threshold | |
81
|---|---:|---:|---:|---|
82
| commit: one file (mean of 4 999) | 3 761 ms | 861 ms | 250 ms | **over** |
83
| status: clean working copy | 2 977 ms | 803 ms | 2 000 ms | ok |
84
| status: 10 files modified | 3 062 ms | 864 ms | 2 000 ms | ok |
85
| commit: 10 files | 9 089 ms | 861 ms | 500 ms | **over** |
86
| log: whole bookmark | 408 ms | 400 ms | 2 000 ms | ok |
87
| blame: hot file | 2 920 ms | 809 ms | 2 000 ms | ok |
88
| blame: ordinary file | 2 927 ms | 828 ms | 1 000 ms | ok |
89
| status after checkpoint | 2 873 ms | 770 ms | 2 000 ms | ok |
90
| push: everything | 782 ms | 742 ms | 60 000 ms | ok |
91
| clone: everything | 3 378 ms | 1 664 ms | 60 000 ms | ok |
92
| fsck | 7 955 ms | 6 872 ms | 60 000 ms | ok |
93
| gc | 9 489 ms | 9 526 ms | 60 000 ms | ok |
94
95
Peak resident memory: 1 145 MiB (was 1 405). The run took 1 h 12 min
96
(was 5 h 14 min). Commit time no longer grows with history; what remains
97
grows with the number of files: at 10 000 files a snapshot spends about
98
320 ms loading the base state, 190 ms materializing it, 130 ms walking the
99
working copy and 40 ms building the change. That is O10b.
0bb9413f Andy McCall ↶ 100
101
## 2026-09-28: after O10b
102
103
Rendering the base state, building file graphs from a checkpoint and
104
reading the working copy now run on all cores. Measured at 10 000 files
105
with 60 and 300 changes (commit time no longer depends on the length of
106
history, so the full 5 000 was not rerun):
107
108
| Phase of one snapshot, 10 000 files | After O10a | After O10b |
109
|---|---:|---:|
110
| load the base state | 320 ms | 180–280 ms |
111
| materialize the base state | 190 ms | 75 ms |
112
| walk and read the working copy | 130 ms | 80 ms |
113
| build the working-copy change | 40 ms | 40 ms |
114
| write the manifest | – | 46 ms |
115
116
| Operation, 10 000 files | After O10a | After O10b | Threshold |
117
|---|---:|---:|---:|
118
| status: clean working copy | 803 ms | 464–581 ms | 2 000 ms |
119
| commit: one file (mean) | 861 ms | 550–605 ms | 250 ms |
120
| commit: 10 files | 861 ms | 583–635 ms | 500 ms |
121
122
Loading the whole base state is now the largest cost. O10c removes it: a
123
snapshot should load and render only the files whose stat changed, which
124
needs checkpoints that can be read per file.