Skip to content

Add parallel event_table mode for audit-log history ingestion - #599

Open
Vedaant-J wants to merge 2 commits into
anle/versioned-features-pocfrom
vedaant/event-table-history
Open

Vedaant-J wants to merge 2 commits into
anle/versioned-features-pocfrom
vedaant/event-table-history

Conversation

@Vedaant-J

Copy link
Copy Markdown
Contributor

Summary

Adds a parallel event_table mode for audit-log history ingestion built on the same HistorySpec / AuditLogSpec user API as #594, targeting anle/versioned-features-poc while leaving the existing versions sidecar path (mode="versions", build_versions, fold.rs, gate.rs, precheck.rs) untouched.

Why a parallel event_table path?

Materializing audited columns into a first-class event table (<table>__events) and updating GraphConfig gives full native compatibility across the DiskGraph / Kumo stack with zero runtime engine changes:

  • Native SamplerEngine point-in-time (TemporalMostRecent, fanout=1) and trajectory (fanout=k) sampling
  • Native Uniform sampling, fetch_features, col_stats / kumo_col_stats (including audit-only categories), _MANIFEST.json / verify_snapshot_integrity, TT-gen, and training loops
  • Zero base Parquet rewrites: mutated columns are projected out of the base TableSpec.columns, leaving base Parquet files untouched on disk while static columns remain on the base table

Key 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 * workers up to 64) to keep peak RSS bounded while parallelizing across cores.
    • Reuses the same HistorySpec / AuditLogSpec and fail-closed VersionsGateError refusal 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).
    • Seeds v0 for all base rows: uses per-row create_time for temporal base tables (catching both tick and sub-tick ordering violations), or 0 (1970-01-01T00:00:00Z) for timeless base tables (stepping back to min_audit_ts - 1 above the DiskGraph NaT floor when pre-1970 audit timestamps are present).
    • Supports forward_filled (default) and sparse layouts, coalesces multi-column edits sharing an index clock tick, preserves full native Arrow types (including 64-bit Float64Array, decimals, UUIDs, timestamps, nulls), and writes Snappy-compressed Parquet shards.
    • Rewrites GraphConfig: drops mutated columns from the base table, registers <table>__events (PK-less, create_time = changed_at, inherits data_version, reverse time-sorted FK <table>__events.<pk> -> <table>.<pk>).
  • packages/diskgraph/diskgraph-pybind/src/lib.rs & python/diskgraph/__init__.py:
    • Exports diskgraph.materialize_event_tables(config_json, history_json, output_dir, *, layout="forward_filled", table_suffix="__events", partitions=None).
    • Extends diskgraph.ingest_with_history(..., mode="versions"|"event_table", layout="forward_filled", event_tables_dir=None, table_suffix="__events", partitions=None) (defaulting to mode="versions" for full backward compatibility) and forwards standard ingest kwargs (col_stats, cat_count_strategy, output_dataplane_dir, success_marker_content, cutoff_col_stats, index_build_id).
  • Tests:
    • Rust integration tests: packages/diskgraph/diskgraph-ingest/tests/versions_event_table.rs (9 tests)
    • Python E2E tests: packages/diskgraph/diskgraph-pybind/python/tests/test_versions_event_table.py (10 tests, including point-in-time oracle cross-check vs mode="versions", trajectory sampling, Uniform sampling, col_stats/kumo_col_stats, and verify_snapshot_integrity)

Benchmarks (Synthetic Multi-Table Graphs: 10M → 100M → 155M Rows)

Evaluated across baseline (no history), versions (#594 sidecar), event_table_ff (forward_filled), and event_table_sparse (sparse) on synthetic delivery (9.16M rows), payments (10.25M & 103.5M rows), and commerce (155M rows + 9.24M heavy audit changes), with --num-threads 16 and isolated subprocess Peak RSS measurement:

Isolated History-Step Scaling (commerce 155M, 9.24M audit changes across 1.15M mutated entities)

History Step Wall Time Speedup Peak RSS Output Size
build_versions (#594) 79.47 s 1.00× 4,474 MB 230.8 MB (sidecar)
materialize_event_tables (forward_filled) 9.01 s 8.82× 1,260 MB (3.55× lower) 91.8 MB (Parquet)
materialize_event_tables (sparse) 8.99 s 8.84× 1,156 MB (3.87× lower) 91.8 MB (Parquet)

End-to-End Summary

Dataset (Rows / Audit Changes) Mode Mat / Ver (s) Total Build (s) Index (MB) Temp f=1 (b/s, p50 ms) Temp f=4 (b/s) Uniform (b/s) TT-Gen (s / rows) Train (steps/s) Oracle vs versions
delivery 10M (9.16M / 17.5K) baseline 0.00 12.85 519.9 1,101 (0.89) 761 670 0.09s / 113K 93.9 —
versions 0.17 13.78 520.4 1,099 (0.88) 770 refused 0.10s / 113K 93.1 baseline
event_table_ff 0.05 13.05 521.8 890 (1.12) 608 529 0.10s / 113K 84.9 12,843/12,843 (100%)
event_table_sparse 0.05 13.03 521.8 880 (1.10) 608 536 0.09s / 113K 81.6 —
payments 10M (10.25M / 170K) baseline 0.00 21.41 744.0 996 (0.99) 664 566 0.40s / 1.80M 69.6 —
versions 1.56 23.13 749.8 949 (1.02) 618 refused 0.41s / 1.80M 68.6 baseline
event_table_ff 0.30 21.90 764.4 766 (1.28) 513 438 0.39s / 1.80M 62.8 16,900/16,900 (100%)
event_table_sparse 0.30 22.10 763.6 745 (1.34) 509 443 0.39s / 1.80M 62.6 —
payments 100M (103.5M / 1.71M) baseline 0.00 97.01 7,185.8 1,049 (0.94) 755 579 1.48s / 18.0M 65.1 —
versions 17.06 118.77 7,244.8 998 (0.99) 711 refused 1.58s / 18.0M 69.3 baseline
event_table_ff 3.15 102.81 7,343.9 801 (1.19) 546 466 1.59s / 18.0M 58.9 13,316/13,316 (100%)
event_table_sparse 3.21 100.24 7,335.6 786 (1.26) 523 437 1.75s / 18.0M 63.9 —
commerce 155M Heavy (155M / 9.24M) baseline 0.00 131.53 7,347.4 1,241 (0.79) 899 653 1.03s / 8.63M 78.0 —
versions 65.57 194.93 7,578.2 1,074 (0.92) 749 refused 1.05s / 8.63M 82.2 baseline
event_table_ff 9.11 138.96 7,679.2 854 (1.15) 538 405 0.93s / 8.63M 77.7 11,310/11,310 (100%)
event_table_sparse 9.03 136.63 7,665.9 880 (1.12) 549 419 0.88s / 8.63M 69.5 —

Verification

  • cargo test -p diskgraph-ingest --test versions_event_table --test versions_fold --test versions_gate: 48 passed, 0 failed
  • cargo test -p diskgraph-pybind --lib: 118 passed, 0 failed
  • cargo clippy -p diskgraph-ingest -p diskgraph-pybind --tests: 0 warnings
  • pytest packages/diskgraph/diskgraph-pybind/python/tests/test_versions.py packages/diskgraph/diskgraph-pybind/python/tests/test_versions_event_table.py: 25 passed, 0 failed

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'.
@copy-pr-bot

copy-pr-bot Bot commented Dec 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@Vedaant-J
Vedaant-J had a problem deploying to gha-kumo-workflow-tests December 4, 2026 02:18 — with GitHub Actions Failure
@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

Parsing warnings: 1

Validation error: Unrecognized key: "tone_instructions" at "reviews"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.
@Vedaant-J

Copy link
Copy Markdown
Contributor Author

Extended Multi-Dimensional Benchmarks & Speed-of-Light (SoL) Analysis

Added a reproducible benchmark & analytical Speed-of-Light suite in packages/diskgraph/scripts/benchmarks/history/ (gen_history_workload.py, bench_history.py, sol_model.py, README.md) so both versions (#594) and event_table modes can be profiled and optimized against the same workloads.

Benchmark Setup

  • Graph: Synthetic 7-table wide-entity payments schema (accounts enriched to 20 mutable feature columns + 3 structural columns; transactions event fact table) across 10M, 25M, 50M, 100M total rows (200K → 2.0M accounts).
  • Mutation distribution: Non-constant Negative Binomial (r=2) per-entity mutation counts calibrated to exact population means 5, 10, 20 mutations/node (up to 40M audit changes on 100M, p95=49, max=236, 15% multi-column co-edits, audit-only categories).
  • Mutated column fractions: 10% (2 cols), 25% (5 cols), 50% (10 cols), 75% (15 cols) out of 20 mutable columns.
  • Measured Host Hardware SoL: 64 vCPU, 249 GiB RAM, NVMe 2.02 GB/s seq read, 1.90 GB/s seq write, 55,867 IOPS 4KB random read (16T, 133 µs 1T latency), 36.5 GB/s STREAM RAM bandwidth (--num-threads 12 per run).
  • Oracle: 100.0000% cell-level match between event_table_ff (fanout=1) and versions across every single configuration below.

1. Scale Sweep (10M → 25M → 50M → 100M, avg_mut=10, 25% = 5/20 cols)

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: versions F1 full-row snapshots pay constant ~1.25 GB bloat even at 10% cols. event_table_ff beats versions on index size through 50% cols and crosses slightly at 75% (+82 MB), while event_table_sparse stays flat at ~7.95 GB (500–581 MB smaller at 75% cols and faster on cold sampling than ff).

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 call advise_random() (MADV_RANDOM) on entries.bin (unlike edges.bin / pk_map). Under tight RAM (MemoryMax=1G/512M), Linux's default 128 KB mmap readahead causes severe page-cache thrashing: versions reads 5,460 MB from NVMe at 512M (8.3× more SSD bytes than event_table_ff's 659 MB), saturating 99.4% of host NVMe 4K IOPS and dropping f=1 throughput to 7.9 b/s (1.75× slower than event_table_ff's 13.9 b/s). Adding MADV_RANDOM should immediately eliminate that ~8× read amplification.
  • Build SoL headroom: build_versions currently runs at ~0.8% of multi-threaded SoL (100% single-core CPU, 17.2 GB RSS at 40M changes); parallelizing + streaming it has ~10–15× wall-time and ~4× RSS headroom. materialize_event_tables currently achieves ~10–12% of multi-threaded SoL (~40–58% of single-thread SoL) with 3–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

This branch had an error being deployed

1 failed (outdated) deployment
gha-kumo-workflow-tests — 8e534a13 Deployed Dec 4, 2026 by Vedaant-J via import #3638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant