sincekit / docs /performance.md
pgg-engineering's picture
Release SinceKit 0.1.0 with native benchmarks and trace replay
ef8334d verified
|
Raw History Blame Contribute Delete
6.41 kB

SinceKit performance

These experiments measure CPU work to prepare exact latest-state replies for readers at different checkpoints. Two results matter for a deployment decision. We measure whether sharing work helps and whether SinceKit is faster than another implementation that already shares it. The fastest equivalent shared plan is the comparator in the first table.

Many-reader planning

Each shared implementation uses the same source index, materializes the same ordered rows and prefix lengths, and receives the same initial reservation. Controls use ordinary binary search, fixed-step binary search with endpoint shortcuts, or a sorted cursor sweep that recognizes already-sorted input. The direct-poll control walks every requested row and only counts it. We verify every reader’s sequence against independent pulls before timing.

Synthetic cursor distribution Readers Shared rows SinceKit µs Fastest other shared plan µs Speedup
contiguous uniform age 2,048 8,188 66.728 106.037 (fixed-step search) 1.59×
churn uniform age 4,096 16,086 158.354 183.312 (fixed-step search) 1.16×
churn presorted age 4,096 16,086 137.544 157.733 (sorted sweep) 1.15×
churn 95pct recent 4,096 16,086 151.895 205.994 (fixed-step search) 1.36×
sparse old gap 2,048 256 6.722 5.852 (fixed-step search) 0.87×
sparse nine hot 3,072 521 11.907 36.919 (binary search) 3.10×
sparse nine hot heartbeat 3,072 521 15.574 49.023 (fixed-step search) 3.15×
sparse rotating17 cold bursts 2,048 1,024 17.040 31.234 (binary search) 1.83×
one reader current 1 0 0.028 0.024 (fixed-step search) 0.86×

Speedup is fastest alternative time divided by SinceKit time. Values below 1 favor the alternative. The portable build used GCC 14.2, -O3 -DNDEBUG -std=c++17, on a shared AMD EPYC 9V74 host pinned to CPU 6. Each value is the median of nine rotated trials after warm-up. The “native” results enable -march=native on the same host. No other machine has independently replicated these figures.

We optimized the sparse-window path on the single-hot-key regime and the nine-hot-key patterns. The rotating seventeen-hot-key generator used an independent seed and was held out from that tuning. Its workload is still synthetic. All development samples, including losses against the sweep and fixed-step controls, are available in the raw files.

Portable samples · Native samples · Development samples · Benchmark source · Machine-readable medians

Replay of observed agent completions

The fixture contains 24,544 timestamped request completions in 325 sessions from Harvard MaDSys FreeInference. Each write updates the session’s latest activity. We generated the reader cadence. Across 64 readers, 79,200 separate logical row deliveries became 23,091 shared rows plus 30,278 prefix lengths. Using 16-byte rows and 8-byte lengths, the prepared representation falls from 1,267,200 to 611,680 bytes before container overhead. Every prefix matched an independent backward history scan. Individual sockets and consumers still have to deliver and apply their data.

Simulated readers SinceKit CPU ms Shared binary search ms Shared sweep ms Speedup vs fastest alternative
64 0.7752 0.8625 0.7945 1.02×
2,048 4.4609 4.6691 4.2476 0.95×

CPU times cover the full replay, including index writes and plan construction. Reading the file, generating schedules, serializing payloads, network delivery and replica application are outside the timer. The real-trace gain can be small and sensitive to CPU scheduling. At a one-second single-reader cadence only four writes coalesced. At a one-minute cadence 17,779 did.

Trace attribution and schedules · Timing source · Raw timing

Choosing the storage engine

The core index bounds each pull by the number of distinct returned keys. A competing compact journal favors sequential traversal and periodically compacts its history. Dense updates and sparse hot keys stress these representations differently. The synthetic comparison times one complete write-and-read trace. Each ordered engine returns the same rows and tombstones. The unordered flat scan in the raw data provides a relaxed-order comparison.

Slots and workload Linked Index ms Optional CompactIndex ms Fastest other ordered engine ms
1,048,576 mixed 4372.449 248.672 383.758 (compact_journal)
65,536 idle 0.029 0.024 0.027 (scan_sorted)
65,536 sparse 0.365 0.250 0.176 (journal)
65,536 hot 1.154 1.298 0.543 (blocks_sorted)
65,536 lagged hot 0.620 6.577 0.622 (std_list)
65,536 dense 21.892 7.874 6.621 (journal)
65,536 mixed 18.708 7.505 6.959 (compact_journal)
65,536 write only 3.540 5.461 0.806 (journal)

The write-only workload charges only writes, with final correctness checked afterward. Its rows say nothing about producing delta plans. Read the full raw results for the per-poll p99 distributions. The million-slot mixed case is especially sensitive to locality. The two compact implementations in the million-slot case were measured separately on the same seed, host and pinned core. Compare those figures with that run-order difference in mind. The native measurements do not establish performance against whole commercial replication products.

Core benchmark method and commands · 65,536 slots · 1,048,576 slots, mixed · Compact baseline, 1M · CompactIndex, 1M

Reproduce

make check replay build/bench build/fanout
./build/fanout --raw > fanout-local.csv
./build/bench --slots 65536 --reps 5 > engine-local.jsonl
python3 bench/summarize.py engine-local.jsonl
c++ -O3 -DNDEBUG -std=c++17 -Iinclude trace/time_plans.cpp -o build/time-plans
./build/time-plans trace/activity.tsv > trace-local.csv