chadtmiller.com/monolith
An atproto PDS
0
0
bench: writes one at a time, the firehose under load, and its replay
bench/README.md+11−4
| @@ -114,13 +114,20 @@ order: | ||
| listRecords | 1000 | 16 | `limit=50` | | ||
| getRepo | 100 | 8 | ~75 records per repo | | ||
| uploadBlob | 100 | 8 | 64 KiB, `application/octet-stream` | | ||
| createRecordSerial | 100 | 1 | one after another, as one person posting: no other write to share a sync with | | ||
| firehose | 100 writes | 20 subscribers | `putRecord`s one after another; latency is the firehose's lag, write answered → commit received | | ||
| firehoseLoaded | 400 writes | 20 subscribers | `putRecord`s 16 at once, each to a different account; latency as for the firehose | | ||
| replay | | 4 subscribers | from cursor 0, as relays catching up: every event of the round, then a write made once all are connected | | ||
| ||
Per part: throughput (requests answered per second), p50 and p99 of request | ||
times, as the best and the median of the rounds. The firehose has no | ||
throughput: with one write at a time it would be the write path's, which | ||
createRecord and applyWrites measure; its times are its lag, from a write's | ||
answer to a subscriber having its commit, 0 when the commit came first. | ||
times, as the best and the median of the rounds. The firehose's live parts | ||
have no throughput: their writes' would be the write path's, which the write | ||
parts measure; their times are the firehose's lag, from a write's answer to | ||
a subscriber having its commit, 0 when the commit came first. replay's | ||
throughput is the events sent to its subscribers per second, until each has | ||
the commit of the write made once all are connected; its times are each | ||
subscriber's, from asking to having that commit. It has 4 subscribers | ||
because zds and vlpds each serve 4 backfills at a time. | ||
| ||
Per server: start time (spawning the server, or `docker start` of its | ||
container, to the first answered `describeServer`), its RSS 2 s after start | ||
bench/results.json+522−319
841 lines changed: not loaded until asked for.
bench/RESULTS.md+137−74
| @@ -9,7 +9,8 @@ way first (each part at a tenth of its size, on accounts of its own), then | ||
runs the parts in order. The raw numbers of every round, and every server's | ||
recorded configuration, are in `bench/results.json`. | ||
| ||
The workload is `harness/perf.mjs`'s, plus `applyWrites` and `listRecords`: | ||
The workload is `harness/perf.mjs`'s, plus `applyWrites`, `listRecords`, | ||
writes one at a time, the firehose under load and its replay: | ||
| ||
| part | requests per round | at once | what | | ||
|---|--:|--:|---| | ||
| @@ -20,12 +21,19 @@ The workload is `harness/perf.mjs`'s, plus `applyWrites` and `listRecords`: | ||
| listRecords | 1000 | 16 | `limit=50` | | ||
| getRepo | 100 | 8 | each repo holds ~25 records from createRecord plus ~50 from applyWrites | | ||
| uploadBlob | 100 | 8 | 64 KiB, `application/octet-stream` | | ||
| createRecordSerial | 100 | 1 | one after another, as one person posting: no other write to share a sync with | | ||
| firehose | 100 writes | 20 subscribers | `putRecord`s one after another; latency is the firehose's lag, write answered → commit received by a subscriber | | ||
| firehoseLoaded | 400 writes | 20 subscribers | `putRecord`s 16 at once, each to a different account; latency as for the firehose | | ||
| replay | | 4 subscribers | from cursor 0, as relays catching up: every event of the round, then a write made once all are connected | | ||
| ||
Throughput is requests answered per second over the part. The firehose has | ||
none: with one write at a time it would be the write path's, which | ||
createRecord and applyWrites measure; its times are its lag, from a write's | ||
Throughput is requests answered per second over the part. The firehose's | ||
live parts have none: their writes' would be the write path's, which the | ||
write parts measure; their times are the firehose's lag, from a write's | ||
answer to a subscriber having its commit, 0 when the commit came first. | ||
replay's throughput is the events sent to its 4 subscribers per second, until | ||
each has the commit of a write made once all are connected (zds and vlpds | ||
each serve 4 backfills at a time); its times are each subscriber's, from | ||
asking to having that commit. | ||
p50/p99 are of the round's request times. "Best" is each column's | ||
best round (most per second, least ms); "median" is the median round. | ||
| ||
| @@ -107,21 +115,24 @@ handler, so the bench kills it rather than wait out `docker stop`. | ||
| ||
### Summary | ||
| ||
Each part's requests per second, start time and memory, each the best round; for the firehose, the p50 of its lag, the best round. Detail follows. | ||
Each part's requests per second (replay: events sent per second), start time and memory, each the best round; for the firehose's live parts, the p50 of their lag, the best round. Detail follows. | ||
| ||
| | reference | spec-pds | vlpds | zds | | ||
|---|--:|--:|--:|--:| | ||
| createAccount per s | 57 | 46 | 32 | 5 | | ||
| createRecord per s | 247 | 373 | 529 | 321 | | ||
| applyWrites per s | 130 | 284 | 272 | 224 | | ||
| getRecord per s | 883 | 13632 | 2985 | 2423 | | ||
| listRecords per s | 575 | 6797 | 2020 | 1472 | | ||
| getRepo per s | 396 | 3860 | 904 | 603 | | ||
| uploadBlob per s | 306 | 315 | 83 | 226 | | ||
| firehose lag p50 ms | 78.5 | 0.4 | 2.3 | 15.0 | | ||
| start ms | 2211 | 49 | 1375 | 435 | | ||
| idle RSS MiB (median) | 397.4 | 18.2 | 169.8 | 16.5 | | ||
| peak RSS MiB | 643.0 | 71.6 | 370.9 | 50.2 | | ||
| createAccount per s | 56 | 50 | 32 | 4 | | ||
| createRecord per s | 242 | 369 | 866 | 314 | | ||
| applyWrites per s | 126 | 280 | 333 | 236 | | ||
| getRecord per s | 873 | 14151 | 3416 | 2311 | | ||
| listRecords per s | 562 | 6537 | 2087 | 1680 | | ||
| getRepo per s | 395 | 3698 | 1367 | 600 | | ||
| uploadBlob per s | 298 | 351 | 99 | 209 | | ||
| createRecordSerial per s | 196 | 181 | 65 | 181 | | ||
| firehose lag p50 ms | 0.5 | 0.3 | 2.4 | 16.9 | | ||
| firehoseLoaded lag p50 ms | 5.9 | 0.6 | 4.1 | not served | | ||
| replay per s | 17715 | 62216 | 18626 | 55013 | | ||
| start ms | 3327 | 42 | 1344 | 426 | | ||
| idle RSS MiB (median) | 397.7 | 18.2 | 170.0 | 16.5 | | ||
| peak RSS MiB | 660.8 | 69.3 | 396.2 | 50.4 | | ||
| ||
### createAccount | ||
| ||
| @@ -129,10 +140,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 57 | 53 | 63.5 | 66.9 | 96.5 | 98.0 | | ||
| spec-pds | 46 | 43 | 83.9 | 87.6 | 118.3 | 126.5 | | ||
| vlpds | 32 | 28 | 118.6 | 135.6 | 184.3 | 228.2 | | ||
| zds | 5 | 5 | 855.9 | 871.0 | 1554.4 | 2163.1 | | ||
| reference | 56 | 53 | 65.0 | 70.4 | 111.4 | 113.7 | | ||
| spec-pds | 50 | 50 | 69.9 | 74.3 | 113.0 | 117.3 | | ||
| vlpds | 32 | 31 | 122.1 | 122.3 | 171.2 | 207.8 | | ||
| zds | 4 | 4 | 676.8 | 709.6 | 1583.8 | 2033.2 | | ||
| ||
### createRecord | ||
| ||
| @@ -140,10 +151,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 247 | 238 | 63.7 | 65.2 | 79.7 | 99.1 | | ||
| spec-pds | 373 | 346 | 43.0 | 45.4 | 81.4 | 91.6 | | ||
| vlpds | 529 | 506 | 23.6 | 24.5 | 65.9 | 66.0 | | ||
| zds | 321 | 287 | 31.3 | 43.4 | 188.6 | 192.6 | | ||
| reference | 242 | 241 | 65.2 | 65.5 | 75.6 | 89.5 | | ||
| spec-pds | 369 | 365 | 42.2 | 42.8 | 71.6 | 76.8 | | ||
| vlpds | 866 | 490 | 17.1 | 23.9 | 55.5 | 98.0 | | ||
| zds | 314 | 306 | 35.3 | 40.2 | 147.2 | 200.5 | | ||
| ||
### applyWrites | ||
| ||
| @@ -151,10 +162,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 130 | 127 | 61.8 | 62.6 | 72.3 | 72.7 | | ||
| spec-pds | 284 | 274 | 27.0 | 27.5 | 44.9 | 49.6 | | ||
| vlpds | 272 | 257 | 22.1 | 22.4 | 58.9 | 67.3 | | ||
| zds | 224 | 215 | 29.1 | 31.4 | 89.8 | 99.5 | | ||
| reference | 126 | 123 | 63.2 | 63.2 | 73.1 | 96.4 | | ||
| spec-pds | 280 | 277 | 27.7 | 27.8 | 45.0 | 45.1 | | ||
| vlpds | 333 | 279 | 19.2 | 20.3 | 64.9 | 65.7 | | ||
| zds | 236 | 229 | 27.5 | 28.6 | 84.9 | 95.9 | | ||
| ||
### getRecord | ||
| ||
| @@ -162,10 +173,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 883 | 858 | 17.6 | 18.0 | 24.4 | 24.6 | | ||
| spec-pds | 13632 | 12253 | 1.0 | 1.1 | 5.4 | 5.7 | | ||
| vlpds | 2985 | 2922 | 3.3 | 3.5 | 40.8 | 43.4 | | ||
| zds | 2423 | 2063 | 4.7 | 5.2 | 41.2 | 44.0 | | ||
| reference | 873 | 834 | 17.9 | 18.6 | 24.7 | 26.0 | | ||
| spec-pds | 14151 | 13622 | 0.9 | 1.0 | 5.6 | 6.1 | | ||
| vlpds | 3416 | 3054 | 3.2 | 3.2 | 40.0 | 43.2 | | ||
| zds | 2311 | 2255 | 4.8 | 4.9 | 46.2 | 47.3 | | ||
| ||
### listRecords | ||
| ||
| @@ -173,10 +184,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 575 | 567 | 26.5 | 27.6 | 42.5 | 58.9 | | ||
| spec-pds | 6797 | 5035 | 1.8 | 2.3 | 11.7 | 14.8 | | ||
| vlpds | 2020 | 1722 | 5.6 | 6.5 | 37.4 | 40.7 | | ||
| zds | 1472 | 1376 | 7.9 | 8.5 | 50.3 | 51.6 | | ||
| reference | 562 | 534 | 27.5 | 28.4 | 38.0 | 56.4 | | ||
| spec-pds | 6537 | 6222 | 2.0 | 2.0 | 12.4 | 13.2 | | ||
| vlpds | 2087 | 1647 | 5.5 | 6.0 | 43.3 | 46.4 | | ||
| zds | 1680 | 1497 | 6.9 | 7.6 | 43.3 | 45.8 | | ||
| ||
### getRepo | ||
| ||
| @@ -184,10 +195,10 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 396 | 393 | 19.1 | 19.2 | 24.8 | 25.3 | | ||
| spec-pds | 3860 | 3700 | 2.0 | 2.0 | 3.1 | 3.4 | | ||
| vlpds | 904 | 738 | 6.2 | 6.7 | 31.9 | 39.6 | | ||
| zds | 603 | 572 | 10.3 | 10.4 | 42.1 | 47.8 | | ||
| reference | 395 | 391 | 19.6 | 19.9 | 23.1 | 23.5 | | ||
| spec-pds | 3698 | 3648 | 2.2 | 2.2 | 2.8 | 3.0 | | ||
| vlpds | 1367 | 1285 | 5.6 | 5.7 | 10.2 | 10.9 | | ||
| zds | 600 | 593 | 9.9 | 10.0 | 42.7 | 44.8 | | ||
| ||
### uploadBlob | ||
| ||
| @@ -195,21 +206,54 @@ Each part's requests per second, start time and memory, each the best round; for | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 306 | 278 | 21.3 | 25.6 | 41.0 | 55.0 | | ||
| spec-pds | 315 | 256 | 18.9 | 20.8 | 53.7 | 69.1 | | ||
| vlpds | 83 | 56 | 93.5 | 114.0 | 173.4 | 378.7 | | ||
| zds | 226 | 208 | 26.2 | 29.3 | 80.4 | 85.8 | | ||
| reference | 298 | 292 | 22.7 | 23.7 | 35.1 | 37.2 | | ||
| spec-pds | 351 | 330 | 18.4 | 19.1 | 40.2 | 45.2 | | ||
| vlpds | 99 | 89 | 79.5 | 91.8 | 129.9 | 138.5 | | ||
| zds | 209 | 184 | 32.1 | 33.6 | 75.4 | 101.4 | | ||
| ||
### createRecordSerial | ||
| ||
100 requests, one after another, as one person posting: no other write to share a sync with. | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 196 | 192 | 4.9 | 4.9 | 7.5 | 14.5 | | ||
| spec-pds | 181 | 180 | 5.4 | 5.4 | 7.0 | 8.2 | | ||
| vlpds | 65 | 61 | 10.5 | 11.2 | 52.8 | 53.0 | | ||
| zds | 181 | 170 | 3.6 | 3.9 | 37.4 | 38.1 | | ||
| ||
### firehose | ||
| ||
100 putRecords one after another, 20 subscribers; each time is the firehose's lag, from a write's answer to a subscriber having its commit, 0 when the commit came first. No rate: with one write at a time it would be the write path's, which createRecord and applyWrites measure. | ||
100 putRecords one after another, 20 subscribers; each time is the firehose's lag, from a write's answer to a subscriber having its commit, 0 when the commit came first. No rate: the writes' would be the write path's, which the write parts measure. | ||
| ||
| impl | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:| | ||
| reference | 78.5 | 113.0 | 304.9 | 333.7 | | ||
| spec-pds | 0.4 | 0.4 | 0.9 | 1.0 | | ||
| vlpds | 2.3 | 2.8 | 31.9 | 37.7 | | ||
| zds | 15.0 | 15.1 | 75.3 | 90.3 | | ||
| reference | 0.5 | 0.6 | 2.3 | 2.7 | | ||
| spec-pds | 0.3 | 0.3 | 0.7 | 0.8 | | ||
| vlpds | 2.4 | 2.4 | 10.9 | 34.0 | | ||
| zds | 16.9 | 17.2 | 84.2 | 85.9 | | ||
| ||
### firehoseLoaded | ||
| ||
400 putRecords, 16 at once, each to a different account, 20 subscribers; each time is the firehose's lag, from a write's answer to a subscriber having its commit, 0 when the commit came first. No rate: the writes' would be the write path's, which the write parts measure. | ||
| ||
| impl | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:| | ||
| reference | 5.9 | 6.0 | 17.5 | 19.9 | | ||
| spec-pds | 0.6 | 0.7 | 15.1 | 23.3 | | ||
| vlpds | 4.1 | 5.1 | 31.5 | 43.8 | | ||
| zds | not served: its live firehose skips commits when writes come at once: of a warm-up of 40 putRecords, 4 at once to 4 accounts, each of 20 subscribers was sent 34 to 37 (its log: `subscribeRepos end start_cursor=466 end_cursor=506 frames=35`), so no lag can be timed for the rest |||| | ||
| ||
### replay | ||
| ||
4 subscribers from cursor 0, as relays catching up: each is sent every event the server made in the round, warm-up and all, then a write made once all are connected. Throughput is the events sent to them all up to that write's commit, per second; each time is a subscriber's, from asking to having that commit (p99: the slowest). | ||
| ||
| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) | | ||
|---|--:|--:|--:|--:|--:|--:| | ||
| reference | 17715 | 17080 | 487.2 | 505.3 | 487.3 | 505.4 | | ||
| spec-pds | 62216 | 58086 | 136.5 | 144.0 | 138.7 | 148.6 | | ||
| vlpds | 18626 | 17613 | 434.8 | 469.4 | 446.5 | 471.7 | | ||
| zds | 55013 | 39172 | 122.9 | 171.7 | 124.9 | 175.4 | | ||
| ||
### Start time and memory | ||
| ||
| @@ -217,16 +261,16 @@ Start: from spawning the server to its first answered `describeServer`, on an em | ||
| ||
| impl | start ms (best) | start ms (median) | idle RSS MiB (median) | peak RSS MiB (best) | peak RSS MiB (median) | | ||
|---|--:|--:|--:|--:|--:| | ||
| reference | 2211 | 2246 | 397.4 | 643.0 | 647.7 | | ||
| spec-pds | 49 | 50 | 18.2 | 71.6 | 83.3 | | ||
| vlpds | 1375 | 1464 | 169.8 | 370.9 | 388.1 | | ||
| zds | 435 | 490 | 16.5 | 50.2 | 50.5 | | ||
| reference | 3327 | 3642 | 397.7 | 660.8 | 661.4 | | ||
| spec-pds | 42 | 52 | 18.2 | 69.3 | 76.6 | | ||
| vlpds | 1344 | 1352 | 170.0 | 396.2 | 398.0 | | ||
| zds | 426 | 441 | 16.5 | 50.4 | 50.5 | | ||
| ||
Not in the table above: what a server needs running beside it, its RSS sampled apart (the sum over its container's processes, from `docker top`, as fast as that answers). | ||
| ||
| impl | beside it | idle MiB (median) | peak MiB (best) | peak MiB (median) | | ||
|---|---|--:|--:|--:| | ||
| vlpds | RustFS | 168.3 | 245.8 | 249.5 | | ||
| vlpds | RustFS | 174.9 | 324.6 | 340.2 | | ||
| ||
vlpds's and zds's RSS are those of their `vlpds` and `zds` processes inside | ||
their containers, from `docker top` (ps in Docker's VM); RustFS's is counted | ||
| @@ -240,7 +284,8 @@ pds.js) were dropped by the user's change of scope before any were cloned or | ||
built. `bench.mjs` takes them as adapters, each pinned in | ||
`bench/impls.json` (README.md, "Adding an implementation"). | ||
| ||
All four servers served every part. | ||
All four servers served every part but one: zds the firehose under load, | ||
as its table says. | ||
| ||
## Caveats | ||
| ||
| @@ -249,11 +294,11 @@ All four servers served every part. | ||
forwarding from the host into the VM, and both reach the PLC directory back | ||
through `host.docker.internal` (vlpds its store over a Docker network too). | ||
That adds latency the native servers don't pay, most visible on the small, | ||
fast reads (getRecord p50 3.3 ms for vlpds and 4.7 ms for zds against | ||
spec-pds's 1.0 ms) [INFERENCE: the forwarding cost was not measured | ||
fast reads (getRecord p50 3.2 ms for vlpds and 4.8 ms for zds against | ||
spec-pds's 0.9 ms) [INFERENCE: the forwarding cost was not measured | ||
apart]. Their start times are from `docker start` of an already created | ||
container to the first answered `describeServer`; vlpds's includes the | ||
~1 s its log shows it waits to acquire its shard's lease, zds's (435–490 ms) | ||
~1 s its log shows it waits to acquire its shard's lease, zds's (426–441 ms) | ||
its SQLite migrations on an empty database. | ||
- **Durability differs, and differently for each.** | ||
- spec-pds syncs every answered write before answering (group-committed, | ||
| @@ -284,25 +329,43 @@ All four servers served every part. | ||
- **vlpds's writes are batched across requests.** Every write on the node goes | ||
into one log, group-committed into segments; with 16 or 8 requests in | ||
flight one segment PUT (7–11 ms to RustFS here) answers many. That is likely | ||
where its createRecord lead comes from (p50 23.6 ms against spec-pds's | ||
43.0 ms); at applyWrites' 8 at once the two are level (272 and 284 per | ||
second). spec-pds group-commits too, but pays a `F_FULLFSYNC` per group | ||
where its createRecord lead comes from (p50 17.1 ms in its best round, | ||
23.9 ms in its median, against spec-pds's 42.2 ms); at applyWrites' 8 at | ||
once the gap narrows (333 and 280 per second best, 279 and 277 median). | ||
spec-pds group-commits too, but pays a `F_FULLFSYNC` per group | ||
[INFERENCE from the two designs; not profiled]. | ||
- **zds's createAccount is slow and serial** (5 per second, p50 856–871 ms | ||
- **One write at a time has no one to share a sync with.** createRecordSerial | ||
is each server's cost of one write alone: spec-pds's `F_FULLFSYNC` (p50 | ||
5.4 ms) against the reference's plain `fsync` (4.9 ms), zds's sync on the | ||
VM's disk (3.6 ms) and vlpds's segment PUT (10.5 ms). spec-pds is the only | ||
one of them known to have the write through the drive's cache when it | ||
answers (above). | ||
- **zds's createAccount is slow and serial** (4 per second, p50 677–710 ms | ||
with 4 at once). One at a time, outside the bench, each took ~140–180 ms; | ||
four at once queue behind each other, as if account creation (a | ||
100,000-round PBKDF2-SHA256 password hash, the signing key, the PLC | ||
genesis operation, the first commit) ran one at a time under its store | ||
lock [INFERENCE from the timings and its source; not profiled]. Its | ||
writes after that (createRecord p50 31 ms, applyWrites 29 ms) are a little | ||
behind vlpds's. | ||
writes after that (createRecord p50 35 ms, applyWrites 28 ms) are behind | ||
vlpds's. | ||
- **zds's firehose skips commits under concurrent writes.** Each of the 20 | ||
subscribers of the warm-up of firehoseLoaded (40 putRecords, 4 at once, | ||
each to a different account) was sent 34 to 37 of the 40 commits, by its | ||
own log (`subscribeRepos end ... frames=`), though the sequence numbers ran | ||
on by 40; written one at a time, every commit reached every subscriber. So | ||
the part is not served for it: no lag can be timed for a commit not sent. | ||
- **replay's events are each server's own.** Every server makes its own | ||
events for the same round (an account's creation is several, and not the | ||
same several everywhere), so replay compares events sent per second, not | ||
the time to send one fixed stream. | ||
- **zds's limit raised.** Its default cap of 4 full `getRepo` exports at once | ||
answers the workload's 8 at once with 429 `RateLimitExceeded`; it was | ||
raised to 8 (`ZDS_MAX_CONCURRENT_REPO_EXPORTS`), as rate limits are off for | ||
the others. Its other caps (32 subscribeRepos connections, 4 cursor | ||
backfills) are above what the workload uses. | ||
- **vlpds's uploadBlob varied** (83 and 56 per second best and median): | ||
each 64 KiB blob is one PUT to RustFS, and its p99 (173–379 ms) is the | ||
backfills at once) are not passed: the firehose parts hold 20 | ||
connections, and replay 4 backfills. | ||
- **vlpds's uploadBlob varied** (99 and 89 per second best and median): | ||
each 64 KiB blob is one PUT to RustFS, and its p99 (130–139 ms) is the | ||
store's, under the load below. | ||
- **Storage engines.** spec-pds: its own append-only logs and files in | ||
`PDS_DATA_DIR` (`spec/STORE.md`), blobs as files. The reference: SQLite | ||
| @@ -319,7 +382,7 @@ All four servers served every part. | ||
- **Memory is not like-for-like.** spec-pds's and the reference's RSS are | ||
from `ps` on macOS; vlpds's and zds's from `ps` inside Docker's Linux VM, | ||
vlpds's under a 2560 MiB container limit its caches size themselves from, | ||
zds's with no limit. RustFS's 168–250 MiB is on top of vlpds's. The PLC | ||
zds's with no limit. RustFS's 175–340 MiB is on top of vlpds's. The PLC | ||
directory runs in the bench's process and is counted for none. The | ||
reference's RSS includes the Node runtime and dev-env's module graph; its | ||
start time is a cold Node start importing `@atproto/dev-env`. | ||
| @@ -332,11 +395,11 @@ All four servers served every part. | ||
the build took ~25 s and produced the same image | ||
(`sha256:124944cb…`); built without that cache it took ~4 minutes here. | ||
- **The machine was not idle.** Other agents' work was running on it (load | ||
average 89 over the minute before the run, just after `--setup`'s build, | ||
~14 at its end, on 8 cores); every round ran under it, so absolute numbers | ||
are lower and noisier than on an idle machine. Best-of-three is reported | ||
for that reason, as `perf.mjs` does. The reference's firehose lag shows it: | ||
p50 78.5 ms in its best round and 113.0 ms in its median. | ||
average ~12 at the start of the run, ~25 at its end, on 8 cores); every | ||
round ran under it, so absolute numbers are lower and noisier than on an | ||
idle machine. Best-of-three is reported for that reason, as `perf.mjs` | ||
does. The reference's firehose lag is the most sensitive to it: in a run | ||
begun at a load average of 89, its p50 was 78.5 ms, against 0.5 ms here. | ||
- One client process drives every server; at spec-pds's read rates | ||
(getRecord ~12–14k/s) the Node client is likely part of the bottleneck | ||
(getRecord ~14k/s) the Node client is likely part of the bottleneck | ||
[INFERENCE]. | ||
harness/bench.mjs+91−38
| @@ -30,6 +30,8 @@ const here = new URL('.', import.meta.url).pathname | ||
// What each implementation runs, pinned: bench/impls.json (lib/impls.mjs). | ||
const vendor = join(root, 'bench', 'vendor') | ||
const pinnedImages = () => [...Object.values(pins.implementations).map((x) => x.image), ...Object.values(pins.images).map((x) => x.image)].filter(Boolean) | ||
// The firehose under load: its writes, this many at once. | ||
const LOADED_WRITERS = 16 | ||
| ||
/// --setup: everything the bench runs, from the pins alone. Run again, it | ||
/// pulls and builds no image it has, and cargo and npm redo nothing up to | ||
| @@ -320,7 +322,9 @@ async function main() { | ||
}, | ||
} | ||
}, | ||
unsupported: {}, | ||
unsupported: { | ||
firehoseLoaded: 'its live firehose skips commits when writes come at once: of a warm-up of 40 putRecords, 4 at once to 4 accounts, each of 20 subscribers was sent 34 to 37 (its log: `subscribeRepos end start_cursor=466 end_cursor=506 frames=35`), so no lag can be timed for the rest', | ||
}, | ||
}, | ||
} | ||
const accountBody = (i, tag) => ({ handle: `${tag}${i}.test`, email: `${tag}${i}@example.com`, password: `bench-password-${i}` }) | ||
| @@ -362,6 +366,48 @@ async function main() { | ||
return out | ||
} | ||
const note = (i) => ({ $type: 'com.example.note', text: `a note of about a hundred bytes, number ${i}, to read back later`, n: i }) | ||
const wsOf = (srv) => `${srv.url.replace(/^http/, 'ws')}/xrpc/com.atproto.sync.subscribeRepos` | ||
| ||
/// `subsN` subscribers, each from an address of its own (spec-pds holds 16 | ||
/// at most from one, spec/LIMITS.md), and `n` putRecords, `writers` at | ||
/// once (no more than there are accounts, so that they go to different | ||
/// ones), over the accounts: each time is the firehose's lag, from a | ||
/// write's answer to a subscriber having its commit, 0 when the commit | ||
/// came first. No rate: the writes' would be the write path's, which the | ||
/// write parts measure. | ||
async function fanOut(srv, st, n, subsN, writers, key) { | ||
const written = new RegExp(`/${st.tag}${key}(\\d+)x$`) | ||
const subs = await Promise.all(Array.from({ length: subsN }, (_, k) => new Promise((ok, fail) => { | ||
const ws = new WebSocket(wsOf(srv), { headers: { 'x-forwarded-for': `198.18.0.${k + 1}` } }) | ||
ws.binaryType = 'arraybuffer' | ||
const sub = { ws, got: new Map() } | ||
ws.onmessage = (m) => { | ||
const [header, body] = cborDecodeMulti(new Uint8Array(m.data)) | ||
if (header?.t !== '#commit') return | ||
for (const op of body.ops ?? []) { | ||
const k = written.exec(op.path) | ||
if (k && !sub.got.has(Number(k[1]))) sub.got.set(Number(k[1]), performance.now()) | ||
} | ||
} | ||
ws.onopen = () => ok(sub) | ||
ws.onerror = () => fail(new Error(`${srv.name}: subscribeRepos`)) | ||
}))) | ||
const answeredAt = [] | ||
await load(n, Math.min(writers, st.accounts.length), async (i) => { | ||
const a = st.accounts[i % st.accounts.length] | ||
await call(srv, 'com.atproto.repo.putRecord', { body: { repo: a.did, collection: 'com.example.note', rkey: `${st.tag}${key}${i}x`, record: { $type: 'com.example.note', text: 'fan-out', n: i } }, token: a.token }) | ||
answeredAt[i] = performance.now() | ||
}) | ||
for (let w = 0; w < 100 && subs.some((s) => s.got.size < n); w++) await new Promise((ok) => setTimeout(ok, 100)) | ||
for (const s of subs) s.ws.close() | ||
const times = [] | ||
for (const s of subs) for (let i = 0; i < n; i++) { | ||
const at = s.got.get(i) | ||
if (at === undefined) throw new Error(`${srv.name}: a subscriber did not get the commit of write ${i} within 10 s`) | ||
times.push(Math.max(0, at - answeredAt[i])) | ||
} | ||
return { times } | ||
} | ||
| ||
/// The parts, in order, each with its size in a measured round and how | ||
/// many requests at once; a warm-up runs each at a tenth of its size. | ||
| @@ -394,43 +440,42 @@ async function main() { | ||
})], | ||
getRepo: [100, 8, (srv, st, n, at) => load(n, at, async (i) => (await call(srv, 'com.atproto.sync.getRepo', { params: { did: st.accounts[i % st.accounts.length].did } })).ms)], | ||
uploadBlob: [100, 8, (srv, st, n, at) => load(n, at, async (i) => (await call(srv, 'com.atproto.repo.uploadBlob', { bytes: blob(i), type: 'application/octet-stream', token: st.accounts[i % st.accounts.length].token })).ms)], | ||
// 20 subscribers, each from an address of its own (spec-pds holds 16 at | ||
// most from one, spec/LIMITS.md), and `n` putRecords one after another: | ||
// each time is the firehose's lag, from a write's answer to a subscriber | ||
// having its commit, 0 when the commit came first. No rate: one write at | ||
// a time makes it the write path's, which createRecord and applyWrites | ||
// measure. | ||
firehose: [100, 20, async (srv, st, n, subsN) => { | ||
// One write at a time, as one person posting: no other write to share | ||
// its sync with. After the reads, so the repos they read are as before. | ||
createRecordSerial: [100, 1, (srv, st, n, at) => load(n, at, async (i) => { | ||
const a = st.accounts[i % st.accounts.length] | ||
return (await call(srv, 'com.atproto.repo.createRecord', { body: { repo: a.did, collection: 'com.example.note', record: note(200000 + i) }, token: a.token })).ms | ||
})], | ||
// 20 subscribers; the writes one after another, then LOADED_WRITERS at once. | ||
firehose: [100, 20, (srv, st, n, subsN) => fanOut(srv, st, n, subsN, 1, 'fh')], | ||
firehoseLoaded: [400, 20, (srv, st, n, subsN) => fanOut(srv, st, n, subsN, LOADED_WRITERS, 'fl')], | ||
// `subsN` subscribers from cursor 0, as relays catching up: each is sent | ||
// every event the server has made, then a write made once all are | ||
// connected. Each time is a subscriber's, from asking to that write's | ||
// commit; the rate is the events sent to all of them before it, per | ||
// second. 4 at once: zds and vlpds each serve 4 backfills at a time. | ||
replay: [4, 4, async (srv, st, n, subsN) => { | ||
const marker = new RegExp(`/${st.tag}replayx$`) | ||
const t = performance.now() | ||
const subs = await Promise.all(Array.from({ length: subsN }, (_, k) => new Promise((ok, fail) => { | ||
const ws = new WebSocket(`${srv.url.replace(/^http/, 'ws')}/xrpc/com.atproto.sync.subscribeRepos`, { headers: { 'x-forwarded-for': `198.18.0.${k + 1}` } }) | ||
const ws = new WebSocket(`${wsOf(srv)}?cursor=0`, { headers: { 'x-forwarded-for': `198.18.0.${k + 1}` } }) | ||
ws.binaryType = 'arraybuffer' | ||
const sub = { ws, got: new Map() } | ||
const sub = { ws, events: 0, done: undefined } | ||
ws.onmessage = (m) => { | ||
if (sub.done !== undefined) return | ||
sub.events++ | ||
const [header, body] = cborDecodeMulti(new Uint8Array(m.data)) | ||
if (header?.t !== '#commit') return | ||
for (const op of body.ops ?? []) { | ||
const k = new RegExp(`/${st.tag}fh(\\d+)x$`).exec(op.path) | ||
if (k && !sub.got.has(Number(k[1]))) sub.got.set(Number(k[1]), performance.now()) | ||
} | ||
if (header?.t === '#commit' && (body.ops ?? []).some((op) => marker.test(op.path))) sub.done = performance.now() | ||
} | ||
ws.onopen = () => ok(sub) | ||
ws.onerror = () => fail(new Error(`${srv.name}: subscribeRepos`)) | ||
ws.onerror = () => fail(new Error(`${srv.name}: subscribeRepos from cursor 0`)) | ||
}))) | ||
const answeredAt = [] | ||
const a = st.accounts[0] | ||
for (let i = 0; i < n; i++) { | ||
await call(srv, 'com.atproto.repo.putRecord', { body: { repo: a.did, collection: 'com.example.note', rkey: `${st.tag}fh${i}x`, record: { $type: 'com.example.note', text: 'fan-out', n: i } }, token: a.token }) | ||
answeredAt[i] = performance.now() | ||
} | ||
for (let w = 0; w < 100 && subs.some((s) => s.got.size < n); w++) await new Promise((ok) => setTimeout(ok, 100)) | ||
await call(srv, 'com.atproto.repo.putRecord', { body: { repo: a.did, collection: 'com.example.note', rkey: `${st.tag}replayx`, record: { $type: 'com.example.note', text: 'caught up' } }, token: a.token }) | ||
for (let w = 0; w < 600 && subs.some((s) => s.done === undefined); w++) await new Promise((ok) => setTimeout(ok, 100)) | ||
for (const s of subs) s.ws.close() | ||
const times = [] | ||
for (const s of subs) for (let i = 0; i < n; i++) { | ||
const at = s.got.get(i) | ||
if (at === undefined) throw new Error(`${srv.name}: a subscriber did not get the commit of write ${i} within 10 s`) | ||
times.push(Math.max(0, at - answeredAt[i])) | ||
} | ||
return { times } | ||
if (subs.some((s) => s.done === undefined)) throw new Error(`${srv.name}: a subscriber from cursor 0 did not catch up within 60 s`) | ||
return { times: subs.map((s) => s.done - t), total: Math.max(...subs.map((s) => s.done)) - t, count: subs.reduce((sum, s) => sum + s.events, 0) } | ||
}], | ||
} | ||
| ||
| @@ -522,8 +567,8 @@ async function main() { | ||
} | ||
for (const [part, [n, at, fn]] of Object.entries(PARTS)) { | ||
if (adapter.unsupported[part]) continue | ||
const { times, total } = await fn(srv, st, n, at) | ||
parts[part] = { p50: pct(times, 50), p99: pct(times, 99), ...(total !== undefined && { rate: (times.length / total) * 1000 }), n: times.length } | ||
const { times, total, count } = await fn(srv, st, n, at) | ||
parts[part] = { p50: pct(times, 50), p99: pct(times, 99), ...(total !== undefined && { rate: ((count ?? times.length) / total) * 1000 }), n: times.length } | ||
} | ||
sampling = false | ||
await sampler | ||
| @@ -590,17 +635,27 @@ function markdown(results) { | ||
const names = Object.keys(results.impls).sort((a, b) => (b === 'reference') - (a === 'reference')) | ||
const lines = [] | ||
const partsOf = Object.keys(results.workload) | ||
lines.push('### Summary', '', "Each part's requests per second, start time and memory, each the best round; for the firehose, the p50 of its lag, the best round. Detail follows.", '') | ||
// The firehose's live parts have no rate: their lag is in the summary. And | ||
// what each part that is not `n` requests, `at` at once, is. | ||
const lagged = new Set(['firehose', 'firehoseLoaded']) | ||
const lagOf = "each time is the firehose's lag, from a write's answer to a subscriber having its commit, 0 when the commit came first. No rate: the writes' would be the write path's, which the write parts measure." | ||
const about = { | ||
createRecordSerial: (n) => `${n} requests, one after another, as one person posting: no other write to share a sync with.`, | ||
firehose: (n, at) => `${n} putRecords one after another, ${at} subscribers; ${lagOf}`, | ||
firehoseLoaded: (n, at) => `${n} putRecords, ${LOADED_WRITERS} at once, each to a different account, ${at} subscribers; ${lagOf}`, | ||
replay: (n, at) => `${at} subscribers from cursor 0, as relays catching up: each is sent every event the server made in the round, warm-up and all, then a write made once all are connected. Throughput is the events sent to them all up to that write's commit, per second; each time is a subscriber's, from asking to having that commit (p99: the slowest).`, | ||
} | ||
lines.push('### Summary', '', "Each part's requests per second (replay: events sent per second), start time and memory, each the best round; for the firehose's live parts, the p50 of their lag, the best round. Detail follows.", '') | ||
lines.push(`| | ${names.join(' | ')} |`, `|---|${names.map(() => '--:').join('|')}|`) | ||
for (const part of partsOf) { | ||
const lag = part === 'firehose' | ||
const lag = lagged.has(part) | ||
const cell = (name) => { | ||
const r = results.impls[name] | ||
if (r.unsupported[part]) return 'not served' | ||
const xs = r.rounds.map((x) => x.parts[part]) | ||
return lag ? Math.min(...xs.map((x) => x.p50)).toFixed(1) : Math.max(...xs.map((x) => x.rate)).toFixed(0) | ||
} | ||
lines.push(`| ${lag ? 'firehose lag p50 ms' : `${part} per s`} | ${names.map(cell).join(' | ')} |`) | ||
lines.push(`| ${lag ? `${part} lag p50 ms` : `${part} per s`} | ${names.map(cell).join(' | ')} |`) | ||
} | ||
const each = (f) => names.map((name) => f(results.impls[name].rounds)).join(' | ') | ||
lines.push(`| start ms | ${each((rs) => Math.min(...rs.map((x) => x.startMs)).toFixed(0))} |`) | ||
| @@ -608,10 +663,8 @@ function markdown(results) { | ||
lines.push(`| peak RSS MiB | ${each((rs) => mib(Math.min(...rs.map((x) => x.peakKiB))).toFixed(1))} |`, '') | ||
for (const part of partsOf) { | ||
const { n, at } = results.workload[part] | ||
const lag = part === 'firehose' | ||
lines.push(`### ${part}`, '', lag | ||
? `${n} putRecords one after another, ${at} subscribers; each time is the firehose's lag, from a write's answer to a subscriber having its commit, 0 when the commit came first. No rate: with one write at a time it would be the write path's, which createRecord and applyWrites measure.` | ||
: `${n} requests, ${at} at once.`, '') | ||
const lag = lagged.has(part) | ||
lines.push(`### ${part}`, '', about[part]?.(n, at) ?? `${n} requests, ${at} at once.`, '') | ||
lines.push( | ||
lag ? '| impl | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |' : '| impl | per s (best) | per s (median) | p50 ms (best) | p50 ms (median) | p99 ms (best) | p99 ms (median) |', | ||
lag ? '|---|--:|--:|--:|--:|' : '|---|--:|--:|--:|--:|--:|--:|', | ||