sincekit / trace /README.md
pgg-engineering's picture
Release SinceKit 0.1.0 with native benchmarks and trace replay
ef8334d verified
|
Raw History Blame Contribute Delete
6.73 kB
# Replay an observed agent workload
The fixture records 24,544 LLM request completions across 325 agent sessions in Harvard MadSys's FreeInference trace. A session owns one latest-activity row. Each completion updates that row. The read schedules below model subscribers to this state. The source observed the writes. SinceKit supplied the readers.
Run from the repository root with a C++17 compiler. The bundled fixture works offline.
```sh
mkdir -p build
c++ -std=c++17 -O2 -Iinclude trace/replay.cpp -o build/trace_replay
./build/trace_replay trace/activity.tsv
```
The program prints JSON and exits unsuccessfully if the index disagrees with an independent oracle. For each requested cursor, the oracle walks the source events backward and takes the first occurrence of each session. It verifies every ID, latest revision, deletion flag, output position and returned cursor. This trace updates session activity throughout and contains zero deletions.
## Results on the bundled fixture
| Poll interval | Simulated polls | Latest rows emitted | Intermediate writes coalesced |
|---|---:|---:|---:|
| 1 second | 382,531 | 24,540 | 4 (0.02%) |
| 10 seconds | 38,254 | 17,467 | 7,077 (28.83%) |
| 1 minute | 6,376 | 6,765 | 17,779 (72.44%) |
| 5 minutes | 1,276 | 2,502 | 22,042 (89.81%) |
| 1 hour | 107 | 686 | 23,858 (97.21%) |
Each run starts with a zero cursor and polls on multiples of the interval after the first completion. Each poll sees all completions through that boundary and immediately acknowledges delivery. A slower consumer needs fewer rows to catch up on this trace. These counts describe the effect of latest-state semantics. Any correct implementation can emit the same rows.
A second run attaches 64 simulated readers to the same index, with periods of 1 through 64 minutes. Queries due on the same tick share one batch plan. Every reader flushes on the first minute boundary after the last write. Across 6,376 plans, independently materializing each reader's list would produce 79,200 rows. The shared representation uses 23,091 rows and 30,278 prefix lengths. This is a **3.43× reduction in row instances**. With 16-byte rows and 8-byte lengths, the two representations account for 1,267,200 and 611,680 bytes respectively, before container overhead. Each reader still consumes its own prefix. The replay measures preparation counts and validates contents, with no network or latency measurements.
## Source and reproduction
The input is the September 1, 2026 JSONL shard from the week beginning August 30. It contains 275 root sessions and 50 nested sessions. Session timelines can extend beyond the shard's calendar date. Recorded completions in this file span September 1 at 00:00:48.992 UTC through September 5 at 10:16:19.849 UTC. This single shard samples a particular population of agents and workload mix. [Dataset and schema](https://huggingface.co/datasets/harvardMadsys/freeinference_agentic_trace)
The original dataset is **FreeInference Agentic Trace**, by William Nixon, Muxin Tian, Yunjia Zheng, Haryadi S. Gunawi and Juncheng Yang, released under CC BY 4.0. The derived `activity.tsv` retains the CC BY 4.0 license. SinceKit recursively extracts request completion times and session identifiers, sorts by completion time, source session identifier and request step, assigns ascending dense IDs in order of first completion and subtracts the first completion time. The two tab-separated integers on each line are elapsed milliseconds and dense session ID. All source prompts, tool arguments and user identifiers are excluded. [Paper](https://doi.org/10.5281/zenodo.23903440) · [License](https://creativecommons.org/licenses/by/4.0/)
| File | SHA-256 |
|---|---|
| [Pinned source shard](https://huggingface.co/datasets/harvardMadsys/freeinference_agentic_trace/resolve/bb26cf72c9c20f2b05f765d88548156a74d3c253/release/2026-08-30_2026-09-05/traces/2026-09-01.jsonl.zst) | `e73649253f159ae41cd5ebb10bf09927268e84342fc2f5a7378c66568b99e566` |
| `activity.tsv` | `d329d0ea419c4a475be6863607d7e551e24f8970858f95a5b7818793087e75eb` |
To reproduce the fixture, run `python3 trace/project.py`. The script verifies both checksums. Regeneration uses the streaming parser `ijson` (`python3 -m pip install ijson`). Decompression uses Python 3.14's standard library or the `zstandard` package on earlier Python versions. To use a local copy of the pinned shard, pass `--source path/to/2026-09-01.jsonl.zst`.
## CPU cost on the recorded writes
All three methods built the same owned rows and per-reader prefix lengths. The binary-search baseline walked the union once and used `std::lower_bound` for each cursor. The sweep baseline checked for descending cursor order and used a single forward walk when possible, falling back to binary search otherwise. All methods received the same reservation hint and equal-cursor shortcut.
| Simulated readers | Method | Median CPU ms per replay | Median elapsed ms per replay |
|---:|---|---:|---:|
| 64 | SinceKit | 0.775 | 0.775 |
| 64 | Shared union + binary search | 0.863 | 0.863 |
| 64 | Ordered sweep + binary fallback | 0.795 | 0.815 |
| 2,048 | SinceKit | 4.461 | 4.598 |
| 2,048 | Shared union + binary search | 4.669 | 4.670 |
| 2,048 | Ordered sweep + binary fallback | 4.248 | 4.663 |
SinceKit used 2.4% less median CPU time than the sweep at 64 readers and 5.0% more at 2,048. Elapsed time includes descheduling, and run-to-run variation on this shared host exceeded those differences. The sample supports a near tie on this trace. [Raw timings](timing.csv)
The benchmark repeats all 24,544 writes and 6,376 planning ticks from an empty index. Reader periods are one through 64 or one through 2,048 minutes, with a final flush for all readers. Timing includes index construction, writes, plan building and destruction. Input parsing, the precomputed reader schedule, application payloads and network delivery are outside the measurement. An untimed pass hashes the revision, every row and every prefix length and requires agreement across the three methods.
Reproduce on Linux from the repository root. Substitute an available CPU for `1` if needed. The recorded run used an AMD EPYC 9V74 VM, GCC 14.2.0 and generic x86-64 compiler settings.
```sh
mkdir -p build
g++ -O3 -DNDEBUG -std=c++17 -Iinclude trace/time_plans.cpp -o build/time_plans
taskset -c 1 ./build/time_plans trace/activity.tsv > build/trace-timing.csv
```
One warm-up precedes 12 recorded trials. Each method runs eight complete replays per trial, with the method order rotated. Divide each CSV duration by `replays` and then take the median across trials per method and reader count. `cpu_ns` reports process CPU time and `elapsed_ns` uses the monotonic clock.