Repository navigation
Conversation
Add a parallel history-ingestion path (materialize_event_tables and ingest_with_history(..., mode='event_table')) alongside the existing versions sidecar path, leaving mode='versions' untouched. - Streams and hash-partitions audit logs and projected base-table columns into bounded-concurrency waves (no base Parquet rewrite; mutable columns are projected out of base TableSpec.columns). - Seeds v0 for all base rows at create_time (temporal tables) or 0 (1970-01-01 for timeless tables, stepping below min_audit_ts for pre-1970 audit data) and emits forward_filled or sparse Parquet event tables with reverse time-sorted FK edges. - Inherits data_version on generated event tables for kumo_col_stats and forwards standard ingest kwargs (including success_marker_content) from ingest_with_history. - Adds Rust integration tests and Python E2E tests including a 100% point-in-time oracle check against mode='versions'.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Add scripts under packages/diskgraph/scripts/benchmarks/history/ so engineers can benchmark and optimize both versions and event_table modes end-to-end: - gen_history_workload.py: streaming vectorized generator for variable (Negative Binomial) mutation density (5/10/20 avg/node) and mutated-column-fraction sweeps (10%/25%/50%/75%) with --verify. - bench_history.py: isolated-subprocess benchmarks measuring wall time, CPU%, Peak RSS, /proc/self/io SSD read/write MB, major page faults, warm & cgroup MemoryMax-capped cold-NVMe sampling, TT-gen, PyTorch GNN training, and 100% point-in-time oracle verification. - sol_model.py: first-principles storage, build, and cold-NVMe sampling Speed-of-Light (SoL) calculator comparing measured vs hardware bounds. - README.md: reproduction and optimization triage guide.
Extended Multi-Dimensional Benchmarks & Speed-of-Light (SoL) AnalysisAdded a reproducible benchmark & analytical Speed-of-Light suite in Benchmark Setup
1. Scale Sweep (
|
| Rung (Audit Changes) | Mode | Iso Hist (s) | Iso Peak RSS (MB) | Iso CPU% | Total Build (s) | Index (MB) | Warm f=1 (b/s / p50 ms) | Cold f=1 (b/s / p50 ms) | Cold SSD-R (MB) | TT-Gen (s) | Train CPU (st/s) | Hist Build % SoL (MT / 1T) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 10M (2M) | baseline |
— | — | — | 22.0 | 750.2 | 842 / 1.18 | 22.3 / 38.5 | 153 | 0.43 | 22.6 | — |
versions |
19.50 | 1,032 | 100% | 41.6 | 874.3 | 770 / 1.27 | 36.6 / 22.8 | 214 | 0.46 | 21.5 | 0.8% / 7.9% | |
event_table_ff |
1.79 | 423 | 263% | 24.0 | 835.7 | 670 / 1.49 | 29.0 / 29.9 | 192 | 0.44 | 17.7 | 10.1% / 42.9% | |
event_table_sparse |
1.81 | 487 | 258% | 23.8 | 820.0 | 626 / 1.59 | 30.0 / 26.4 | 185 | 0.46 | 17.5 | 9.9% / 41.4% | |
| 25M (4M) | baseline |
— | — | — | 43.8 | 1,466.1 | 839 / 1.17 | 36.9 / 22.9 | 155 | 0.75 | 16.8 | — |
versions |
39.32 | 1,969 | 100% | 82.5 | 1,715.0 | 762 / 1.29 | 37.3 / 23.5 | 216 | 0.67 | 17.0 | 0.8% / 7.8% | |
event_table_ff |
3.57 | 838 | 278% | 47.4 | 1,637.6 | 637 / 1.58 | 29.0 / 28.6 | 198 | 0.67 | 12.5 | 10.2% / 43.0% | |
event_table_sparse |
3.62 | 781 | 288% | 48.8 | 1,605.8 | 624 / 1.59 | 28.1 / 27.4 | 190 | 0.66 | 10.6 | 10.0% / 41.4% | |
| 50M (10M) | baseline |
— | — | — | 85.9 | 3,684.7 | 837 / 1.17 | 36.7 / 24.3 | 165 | 1.24 | 13.2 | — |
versions |
100.51 | 4,867 | 100% | 185.7 | 4,307.8 | 771 / 1.27 | 29.1 / 23.8 | 231 | 1.34 | 12.1 | 0.8% / 7.7% | |
event_table_ff |
9.22 | 1,485 | 295% | 98.2 | 4,114.0 | 626 / 1.58 | 21.3 / 31.8 | 220 | 2.08 | 10.1 | 9.8% / 41.7% | |
event_table_sparse |
9.05 | 1,388 | 292% | 93.3 | 4,034.2 | 521 / 1.75 | 28.4 / 29.7 | 212 | 1.43 | 6.5 | 10.0% / 41.5% | |
| 100M (20M) | baseline |
— | — | — | 104.2 | 7,246.3 | 918 / 1.10 | 34.8 / 25.4 | 171 | 2.26 | 11.3 | — |
versions |
200.80 | 9,632 | 100% | 303.9 | 8,501.4 | 762 / 1.27 | 32.9 / 24.8 | 245 | 2.51 | 13.3 | 0.8% / 7.7% | |
event_table_ff |
17.89 | 2,426 | 301% | 127.7 | 8,084.1 | 639 / 1.56 | 27.2 / 31.8 | 232 | 2.45 | 7.1 | 10.2% / 43.0% | |
event_table_sparse |
18.50 | 2,371 | 300% | 131.1 | 7,924.3 | 673 / 1.49 | 17.3 / 36.4 | 236 | 2.71 | 7.9 | 9.8% / 40.6% |
2. Mutated-Column-Fraction Sweep (10%, 25%, 50%, 75% of 20 mutable cols @ 100M, avg_mut=10, 20M changes)
| Col Frac | Mode | Iso Hist (s) | Iso RSS (MB) | Index (MB) | Sidecar / Evt Pq (MB) | Warm f=1 (b/s) | Cold f=1 (b/s) | Cold SSD-R (MB) | TT-Gen (s) | Train CPU (st/s) |
|---|---|---|---|---|---|---|---|---|---|---|
| 10% (2c) | versions |
199.0 | 9,628 | 8,518.9 | 1,272.7 / 0.0 | 752 | 34.5 | 245.9 | 2.49 | 13.5 |
event_table_ff |
16.9 | 2,262 | 7,999.4 | 0.0 / 261.7 | 631 | 27.5 | 233.0 | 2.51 | 5.6 | |
event_table_sparse |
19.1 | 2,240 | 7,937.8 | 0.0 / 249.2 | 612 | 27.5 | 235.6 | 3.10 | 5.3 | |
| 25% (5c) | versions |
200.8 | 9,632 | 8,501.4 | 1,255.1 / 0.0 | 762 | 32.9 | 244.9 | 2.51 | 13.3 |
event_table_ff |
17.9 | 2,426 | 8,084.1 | 0.0 / 275.9 | 639 | 27.2 | 232.0 | 2.45 | 7.1 | |
event_table_sparse |
18.5 | 2,371 | 7,924.3 | 0.0 / 248.8 | 673 | 17.3 | 235.5 | 2.71 | 7.9 | |
| 50% (10c) | versions |
205.5 | 9,626 | 8,467.0 | 1,220.7 / 0.0 | 755 | 29.6 | 243.0 | 2.44 | 13.3 |
event_table_ff |
18.7 | 2,978 | 8,351.3 | 0.0 / 348.8 | 637 | 26.7 | 238.9 | 2.23 | 10.1 | |
event_table_sparse |
18.8 | 2,896 | 7,948.7 | 0.0 / 292.0 | 646 | 27.7 | 229.5 | 2.23 | 7.5 | |
| 75% (15c) | versions |
204.5 | 9,662 | 8,487.1 | 1,240.8 / 0.0 | 761 | 29.0 | 244.2 | 2.37 | 12.9 |
event_table_ff |
20.3 | 3,261 | 8,568.6 | 0.0 / 383.6 | 619 | 24.9 | 245.4 | 2.21 | 10.3 | |
event_table_sparse |
20.2 | 3,126 | 7,987.7 | 0.0 / 312.6 | 641 | 28.4 | 229.1 | 2.20 | 7.8 |
- Storage crossover:
versionsF1 full-row snapshots pay constant ~1.25 GB bloat even at 10% cols.event_table_ffbeatsversionson index size through 50% cols and crosses slightly at 75% (+82 MB), whileevent_table_sparsestays flat at~7.95 GB(500–581 MBsmaller at 75% cols and faster on cold sampling thanff).
3. Mutation-Density Sweep (avg_mut = 5, 10, 20 @ 100M, 25% = 5/20 cols — up to 40M audit changes)
| Avg Mut/Node (Changes) | Mode | Iso Hist (s) | Iso RSS (MB) | Total Build (s) | Index (MB) | Sidecar / Evt Pq (MB) | Cold f=1 (b/s / p50 ms) | Cold SSD-R f=1 (MB) |
|---|---|---|---|---|---|---|---|---|
| 5 (10M) | versions |
125.2 | 5,990 | 229.3 | 7,878.2 | 632.0 / 0.0 | 28.6 / 26.1 | 156.7 |
event_table_ff |
10.7 | 1,496 | 116.2 | 7,707.5 | 0.0 / 171.0 | 21.8 / 29.9 | 170.6 | |
event_table_sparse |
9.9 | 1,557 | 112.8 | 7,632.1 | 0.0 / 154.8 | 28.2 / 30.3 | 166.6 | |
| 10 (20M) | versions |
200.8 | 9,632 | 303.9 | 8,501.4 | 1,255.1 / 0.0 | 32.9 / 24.8 | 180.7 |
event_table_ff |
17.9 | 2,426 | 127.7 | 8,084.1 | 0.0 / 275.9 | 27.2 / 31.8 | 177.8 | |
event_table_sparse |
18.5 | 2,371 | 131.1 | 7,924.3 | 0.0 / 248.8 | 17.3 / 36.4 | 183.2 | |
| 20 (40M) | versions |
368.7 | 17,184 | 476.0 | 9,760.8 | 2,514.5 / 0.0 | 28.4 / 22.6 | 235.2 |
event_table_ff |
39.1 | 4,111 | 153.6 | 8,822.4 | 0.0 / 491.6 | 24.2 / 34.7 | 186.5 | |
event_table_sparse |
36.7 | 4,393 | 140.5 | 8,487.1 | 0.0 / 426.2 | 21.2 / 32.1 | 186.0 |
4. Cgroup MemoryMax Cold-NVMe Simulation (50M m20_c25, 20M changes, 3.6–4.8 GB indexes)
Simulating larger-than-RAM (1B–50B-style) SSD-bound regimes via systemd-run --user --scope -p MemoryMax=<cap> -p MemorySwapMax=0 + POSIX_FADV_DONTNEED (200 batches × 256 uniform random entities):
| Mode (Index GB) | unlimited f=1 b/s |
4G f=1 b/s (SSD MB) |
2G f=1 b/s (SSD MB) |
1G f=1 b/s (SSD MB) |
512M f=1 b/s (SSD MB / % NVMe 4K SoL) |
1G TT-Gen (s / SSD MB) |
|---|---|---|---|---|---|---|
baseline (3.60) |
299.6 | 18.5 (422) | 21.3 (422) | 18.4 (422) | 20.7 (422 MB / 20.0%) | 1.35s / 730 |
versions (4.82) |
423.1 | 16.1 (1,606) | 17.1 (1,606) | 11.3 (2,639) | 7.9 (5,460 MB / 99.4%) | 1.62s / 2,028 |
event_table_ff (4.38) |
653.8 | 12.9 (643) | 12.6 (650) | 13.6 (643) | 13.9 (659 MB / 21.0%) | 1.52s / 862 |
event_table_sparse (4.22) |
459.3 | 14.0 (632) | 12.4 (632) | 14.3 (632) | 14.0 (649 MB / 20.8%) | 1.42s / 862 |
Actionable Finding for #594 (versions sidecar)
diskgraph-index/src/versions.rs:221-230(map_file) does not calladvise_random()(MADV_RANDOM) onentries.bin(unlikeedges.bin/pk_map). Under tight RAM (MemoryMax=1G/512M), Linux's default 128 KB mmap readahead causes severe page-cache thrashing:versionsreads 5,460 MB from NVMe at512M(8.3× more SSD bytes thanevent_table_ff's659 MB), saturating 99.4% of host NVMe 4K IOPS and droppingf=1throughput to7.9 b/s(1.75× slower thanevent_table_ff's13.9 b/s). AddingMADV_RANDOMshould immediately eliminate that ~8× read amplification.- Build SoL headroom:
build_versionscurrently runs at~0.8%of multi-threaded SoL (100%single-core CPU,17.2 GBRSS at 40M changes); parallelizing + streaming it has ~10–15× wall-time and ~4× RSS headroom.materialize_event_tablescurrently achieves~10–12%of multi-threaded SoL (~40–58%of single-thread SoL) with3–4×lower RSS; further gains come from parallelizing Pass 1/2 Parquet scans.
Reproducing Locally
# 1. Generate a standalone wide-entity workload (or point --dataset-dir at any local dataset)
python packages/diskgraph/scripts/benchmarks/history/gen_history_workload.py \
--synthetic-rows 200000 --avg-mutations 10 --mut-col-frac 0.25 --verify --out-dir ./wl
# 2. Run warm + cgroup-capped cold-NVMe benchmarks + SoL comparison
python packages/diskgraph/scripts/benchmarks/history/bench_history.py \
--config ./wl/config.json --history ./wl/history.json \
--work-dir ./bench_run --entity-table entities --event-fact-table events \
--cold-sampling --memory-max 1G --output-json ./results.json
Summary
Adds a parallel
event_tablemode for audit-log history ingestion built on the sameHistorySpec/AuditLogSpecuser API as #594, targetinganle/versioned-features-pocwhile leaving the existingversionssidecar path (mode="versions",build_versions,fold.rs,gate.rs,precheck.rs) untouched.Why a parallel
event_tablepath?Materializing audited columns into a first-class event table (
<table>__events) and updatingGraphConfiggives full native compatibility across the DiskGraph / Kumo stack with zero runtime engine changes:SamplerEnginepoint-in-time (TemporalMostRecent,fanout=1) and trajectory (fanout=k) samplingUniformsampling,fetch_features,col_stats/kumo_col_stats(including audit-only categories),_MANIFEST.json/verify_snapshot_integrity, TT-gen, and training loopsTableSpec.columns, leaving base Parquet files untouched on disk while static columns remain on the base tableKey Changes
packages/diskgraph/diskgraph-ingest/src/versions/event_table.rs:materialize_event_tables&materialize_event_tables_in_temp: 3-pass streaming hash-partitioned pipeline (gxhash64(pk) % P) with bounded-concurrency Pass 3 waves (workers = clamp(2..16),P = 4 * workersup to 64) to keep peak RSS bounded while parallelizing across cores.HistorySpec/AuditLogSpecand fail-closedVersionsGateErrorrefusal contract (UNKNOWN_TABLE,SNAPSHOT_SPEC,NEW_ROW,NEW_COLUMN,PRIMARY_KEY,FOREIGN_KEY,CREATE_TIME,NOT_AFTER_CREATE_TIME,DUPLICATE_CELL_TIME,OLD_VALUE_MISMATCH,UNPARSABLE,DUPLICATE_PKS).v0for all base rows: uses per-rowcreate_timefor temporal base tables (catching both tick and sub-tick ordering violations), or0(1970-01-01T00:00:00Z) for timeless base tables (stepping back tomin_audit_ts - 1above the DiskGraphNaTfloor when pre-1970 audit timestamps are present).forward_filled(default) andsparselayouts, coalesces multi-column edits sharing an index clock tick, preserves full native Arrow types (including 64-bitFloat64Array, decimals, UUIDs, timestamps, nulls), and writes Snappy-compressed Parquet shards.GraphConfig: drops mutated columns from the base table, registers<table>__events(PK-less,create_time = changed_at, inheritsdata_version, reverse time-sorted FK<table>__events.<pk> -> <table>.<pk>).packages/diskgraph/diskgraph-pybind/src/lib.rs&python/diskgraph/__init__.py:diskgraph.materialize_event_tables(config_json, history_json, output_dir, *, layout="forward_filled", table_suffix="__events", partitions=None).diskgraph.ingest_with_history(..., mode="versions"|"event_table", layout="forward_filled", event_tables_dir=None, table_suffix="__events", partitions=None)(defaulting tomode="versions"for full backward compatibility) and forwards standardingestkwargs (col_stats,cat_count_strategy,output_dataplane_dir,success_marker_content,cutoff_col_stats,index_build_id).packages/diskgraph/diskgraph-ingest/tests/versions_event_table.rs(9 tests)packages/diskgraph/diskgraph-pybind/python/tests/test_versions_event_table.py(10 tests, including point-in-time oracle cross-check vsmode="versions", trajectory sampling,Uniformsampling,col_stats/kumo_col_stats, andverify_snapshot_integrity)Benchmarks (Synthetic Multi-Table Graphs: 10M → 100M → 155M Rows)
Evaluated across
baseline(no history),versions(#594 sidecar),event_table_ff(forward_filled), andevent_table_sparse(sparse) on syntheticdelivery(9.16M rows),payments(10.25M & 103.5M rows), andcommerce(155M rows + 9.24M heavy audit changes), with--num-threads 16and isolated subprocess Peak RSS measurement:Isolated History-Step Scaling (
commerce155M, 9.24M audit changes across 1.15M mutated entities)build_versions(#594)79.47 s1.00×4,474 MB230.8 MB(sidecar)materialize_event_tables(forward_filled)9.01 s8.82×1,260 MB(3.55× lower)91.8 MB(Parquet)materialize_event_tables(sparse)8.99 s8.84×1,156 MB(3.87× lower)91.8 MB(Parquet)End-to-End Summary
versionsdelivery10M (9.16M / 17.5K)baselineversionsevent_table_ffevent_table_sparsepayments10M (10.25M / 170K)baselineversionsevent_table_ffevent_table_sparsepayments100M (103.5M / 1.71M)baselineversionsevent_table_ffevent_table_sparsecommerce155M Heavy (155M / 9.24M)baselineversionsevent_table_ffevent_table_sparseVerification
cargo test -p diskgraph-ingest --test versions_event_table --test versions_fold --test versions_gate: 48 passed, 0 failedcargo test -p diskgraph-pybind --lib: 118 passed, 0 failedcargo clippy -p diskgraph-ingest -p diskgraph-pybind --tests: 0 warningspytest packages/diskgraph/diskgraph-pybind/python/tests/test_versions.py packages/diskgraph/diskgraph-pybind/python/tests/test_versions_event_table.py: 25 passed, 0 failed