Skip to content

bench: virtual-dataset performance corpus, harness, baselines + audit (pre-work for the perf PR series) - #1475

Closed
aaj3f wants to merge 24 commits into
mainfrom
bench/virtual-dataset-corpus
Closed

aaj3f wants to merge 24 commits into
mainfrom
bench/virtual-dataset-corpus

Conversation

@aaj3f

@aaj3f aaj3f commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

What this is

Benchmark infrastructure + evidence base grounding the upcoming virtual-dataset (Iceberg/R2RML) performance PR series. No engine-pathway code changes — the only engine-adjacent change is implementing the reserved BenchSpanLayer stub in fluree-bench-support.

Contents

Audit series (docs/audit/2026-07-virtual-dataset-perf/): 00-benchmark-brief (2-page findings summary), 01-pathway-inventory (every perf strategy on the R2RML/Iceberg path with trigger/bypass conditions, adversarially verified), 02-hypothesis-map (H1–H8), 03-corpus-design (26 BI questions → 54 queries), 04-findings-register (grounded findings incl. 3 correctness bug classes), 05-diagnosis (six deep-dives; master bottleneck: decode is file-count-bound at ~200ms/file × 7,670 files/fact table), ROADMAP (ranked 9-PR slate, correctness-first, each with corpus-grounded impact + DoD).

Harness (fluree-bench-virtual, bin vbench): 54-query tagged corpus; native/virtual targets; hot/cold protocols (true cold via home-scoped cache + subprocess); per-query pathway counters from trace spans; canonical result hashing against native-blessed oracles (hash_gate policy for nondeterministic-selection queries); budget-gated compare for PR regression checks (native budgets included — virtual wins can't silently regress native); self-contained HTML dashboard.

Baselines (committed): 52 expected-result oracles blessed from native; perf medians for native-SF01 and virtual-SF01 (hot + cold subset).

fluree-bench-support: BenchSpanLayer implemented (allowlisted span capture w/ late-recorded fields, in-memory sink, file: JSONL mode).

Headline evidence (SF01 parity pair: identical data, native ledger vs live Snowflake Iceberg)

  • 24 ok / 30 DNF(≥120–180s) of 54; completing queries: 17 hash-exact, 2 policy-exempt, 5 divergent → 3 root-caused correctness bug classes (silent-empty transitive paths, silent-empty subqueries, missing rdf:type on bound-subject wildcards).
  • Ratios by mechanism: 1–2× where strategies fire (date pruning, fused aggregates, LIMIT pushdown) · 10–13× filtered fact scans · 150–3,400× floor-dominated small queries · DNF for the structural pathologies (incl. bare COUNT(*) on any fact table, while the manifest already holds the answer).
  • SF20 survey (200× fact rows): completing queries barely degrade; the same shapes DNF — the wall is structural, not scale.

How to run

See fluree-bench-virtual/README.md. Requires the SF01 fixtures (deterministic generator) + a Snowflake PAT for virtual targets; native-only runs need neither.

Follow-up

PR-0 of the roadmap (correctness batch) stacks on this branch next. Sibling-dataset provenance, corpus determinism policy, and the measurement protocol are documented in the audit dir.

aaj3f added 19 commits July 10, 2026 13:08
…(WP1)

Verified strategy inventory (11 strategies + SPARQL routing) with trigger/
bypass conditions and file:line anchors at a5528e8; corrects 7 claims from
the exploration pass (kill-switch name, != pruning nuance, ScanValue shape,
catalog-session pin API) and completes the env-switch master table.
Hypothesis map H1-H8 links each suspected pathology to the inventory and to
the benchmark evidence that will confirm or refute it.
…pport (WP3)

Fills the reserved stub: allowlisted span capture with creation-time and
late-recorded fields (on_record merging for iceberg.scan_plan counters),
span-lifetime timing, in-memory take() sink, per-layer span_name_filter so
composed subscribers are unaffected, and the FLUREE_BENCH_TRACING=file:
JSONL mode with FLUREE_BENCH_SPAN_ALLOWLIST.
Attempted to falsify H1/H2/H5 and the §0 corrections rather than re-confirm:
- C2 reclassified: '!= never prunes' stands — no NotEq scan filter is ever
  produced on the R2RML path; the engine's degenerate-!= prune is unreachable.
- H2 refined: ORDER BY..LIMIT is a bounded streaming top-k (not a full sort
  buffer) but forwards no budget, so the scan still fully drains; adds the
  fixable-vs-scan-bound split of the four budget-absorbing modifiers.
- H1/H5 survived stronger: zero with_row_filter call sites in the iceberg
  crate; R2rmlTableProvider exposes no count entrypoint.
…P5 spec)

BI-grounded corpus spec with feature tags, hypothesis linkage (H1-H8 each
>=3 queries w/ dims-only controls), expected-row oracles from generator
invariants, order-sensitivity + canonicalization flags. Key A/B pairs:
decimal-vs-date/int pruning on the GL table (H4, the model's only decimal
columns), pure-LIMIT vs ORDER-BY-LIMIT (H2), VALUES-vs-FILTER (H8), SCD-2
current-vs-history correctness oracle. SCD oracle live-verified on
enterprise-sf01: 300,000 current / 390,000 total.
In-process runner over the graph query builders comparing native ledgers vs
R2RML/Iceberg virtual graph sources: corpus manifest w/ closed feature-tag
enum + validation, per-query wall timing (priming + median-of-reps,
adaptive), BenchSpanLayer pathway counters (scan_table/load_table/
parquet_read/scan_plan/oauth_token) w/ spans_missing honesty flags,
canonical result hashing (sorted multiset, float quantization), pacing +
deadline w/ dnf-as-data, JSONL run records w/ env fingerprint, side-by-side
ratio report. Subcommands: setup --verify | run | exec-one | report.
Seed corpus: 5 dims-only smoke queries. Validated end-to-end on
enterprise-sf01 (all ok).
… + oracle caveats

H2 membership now requires an actual LIMIT above the absorbing modifier
(6 queries, entries and matrix reconciled; Q29 gained its claimed LIMIT).
Predicate audit vs enterprise.ttl clean (63 tokens, 0 misspellings).
Cardinality bounds corrected (Q02/Q42/Q10). New bless-from-native section:
native ledger is the correctness oracle; expected-error queries Q43/Q44
must not be blessed from native (no R2RML router there to reject them).
Replaces the 5 seed queries with the corpus-design set: 26 BI questions ->
54 queries (q001-q054), real lineage headers, full feature-tag enum incl.
filter_iri, 16-query smoke subset covering every tag, per-target
expected_status for the error-boundary pair (q043/q044: native ok-empty,
virtual GRAPH-scope error), property-path probes as ok-but-slow H8 perf
probes (live-settled: 18.75s dims-only vs ~ms native). Validated: 13 unit
tests green + full native run, 54/54 ok within expected bounds (max 1.73s).
Adds the DW_SF01 mapping + activates the virtual-sf01 target (registered
against ENTERPRISE_DEMO.DW_SF01, loaded 2026-07-10, exact generator row
counts).
7 findings, each with rows/hash/wall/span evidence + mechanism anchors:
- F1/F2 SILENT correctness bugs: transitive property paths and subqueries
  return empty with status=ok — sub-scopes escape the triple-scoped
  unconverted-pattern error guard (graph.rs:245-253); one fix closes both.
  (Sequence paths decompose to triples and work — slow, H8.)
- F3 confirmed: bound-subject wildcard omits the rr:class rdf:type triple
  (q042 24 vs 21 rows; UI subject inspector loses @type on virtual).
- F5 perf-DNFs incl. the H3 anchor: dims-only OPTIONAL at 377 correlated
  scan_table calls, native 95ms vs virtual DNF@120s.
- F6 positives: fused-agg 1.52x native; date pushdown pruned 98.8% of files.
- F7 harness: iceberg.scan_plan fires only on the pushdown branch.
Corrects q034's manifest note (transitive = silent-empty, not slow-but-ok).
…col (WP6)

- vbench baseline --expected/--perf: blesses per-query oracles from the
  native target (52 expected files; expected-virtual-error queries get none
  by design) + perf medians per target.
- vbench compare --gate: expected-hash + budget-ratio gating (budgets.json,
  query overrides > class defaults; cold advisory-only) with one in-process
  auto-rerun before declaring a perf violation red.
- Cold protocol: run --cache-state cold spawns exec-one --cold children; a
  home-scoped iceberg cache (<home>/.vbench-iceberg-cache via ledger cache
  config) replaces the machine-global $TMPDIR/fluree_binary_cache for
  vbench targets, so cold clears are hermetic and guarded (path assertion
  refuses non-cache dirs; unit-tested).
- Bonus: dashboard subcommand (self-contained HTML) + survey caps.
Validated: 21 tests green; compare --gate self-check exit 0 (ratios ~1.0);
cold q001 virtual: 20.8s cold vs 2.3s warm, forced oauth/loadTable/
parquet_read/scan_plan spans, and result hash MATCHES the native blessed
oracle — end-to-end parity proof across both pipelines.
…less oracles

Every ORDER BY + LIMIT query gains a unique tiebreaker (subject IRI / unique
var) so hash gating stays exact under ties; pure-LIMIT queries where any k
rows are valid gate on row count + invariants via new manifest hash_gate:
rows_only (default full). Register updated: F4 reclassified corpus-defect /
engine exonerated (tie + selection nondeterminism, head-diff verified); F8
added (single-class q001 loads 6 tables — WP7 over-scan lead). All expected
oracles re-blessed from a fresh 54/54-ok native run (native-full-v2) since
amended queries invalidate their previous hashes.
rows_only queries gate on row count + invariants instead of exact hash
(nondeterministic-selection queries per the corpus determinism policy).
… SF20 survey

- perf/virtual-sf01.json: all 54 hot records (4 merged run files; 24 ok /
  30 dnf) + 6-query cold subset (q001 cold 19.4s vs 2.2s hot; the 5
  already-DNF queries stay DNF cold).
- Error-boundary expectations corrected from observation: q043 lang-tag
  object is ok/0-rows on virtual (GRAPH-error expectation was wrong; oracle
  now blessed), q044 custom-datatype burns to DNF instead of erroring.
- SF20 survey (16 smoke queries, informational): completing queries barely
  degrade at 200x fact scale (fused-agg 1.6s, date-pruned scan 427K rows in
  4.2s) while the same four pathologies DNF identically — the wall is
  structural, not scale-induced. Survey runs are bless-refused by design.
- Final dashboard over all four run sets at results/dashboard.html
  (gitignored).
…ter ranking

Master bottleneck: decode is FILE-COUNT-bound (~200ms fixed per file x 7,670
files per fact table / 8-way concurrency cap ≈ 197s → DNF; measured ~39
files/s across three independent DNF shapes). Most fact queries never reach
their downstream operators — H6/H3 are gated behind H1. COUNT(*) prints the
exact answer (manifest estimated_row_count) then decodes everything anyway.
F8 root-caused: shared base predicate (edw:name) fans the star to 6 dims;
class fusion correctly refuses. Toggle proofs: LIMIT_PUSHDOWN=0 reproduces
the ORDER-BY DNF exactly; FUSED_AGG=0 = 1.48x. No wrong-turn redesigns —
architecture sound, under-optimized for tiny-file reality + shared-predicate
stars.
…orpus-gated

PR-0 correctness (silent-empty loud-refuse guard + bound-subject rdf:type)
→ PR-1 COUNT(*) manifest shortcut → PR-2 H1 decode-wall levers (per-file
cost decomposition first, concurrency cap, manifest fast paths; compaction
as data-side guidance only) → PR-3 star over-scan → PR-4 parent-lookup
memoization → PR-5 scan-side top-k (design sketch) → PR-6 fused-agg-over-
join (gated behind PR-2) → PR-7 decimal pushdown + counters → PR-8 cold/
floor caching program. Every PR carries corpus-grounded impact (which
queries flip), risk/blast-radius, kill-switch semantics, and the shared
DoD: targets at goal + no corpus regression + parity + W3C + BSBM/native
budgets + switch-off = old behavior. The corpus is the contract.
aaj3f added 4 commits July 13, 2026 16:50
…ity)

cargo fmt --all was drifted on 9 of this PR's files (57 hunks) and
fluree-bench-virtual tripped 5 workspace-denied clippy lints
(uninlined_format_args x3, needless_raw_string_hashes,
redundant_closure_for_method_calls) — both invisible locally because CI
only fires on main-based PRs, both red the moment this stack retargets
main. Fixed at the stack base so the children restack onto clean files.
Also folds the is_some_and/is_none_or clippy suggestions (warn-level)
while touching the same lines. 76/76 crate tests green.
…cold flags, budget floor

Harness-trust items from the PR #1475 review, all harness-side (no engine
code touched):

- baseline --expected now REFUSES to overwrite a blessed oracle whose
  hash/rows differ from the run (prints the per-query rows/hash delta,
  writes nothing) unless --force — a native regression that still exits
  ok can no longer be silently blessed as the new truth. An identical
  re-bless is diff-free (original provenance kept); rows_only oracles
  compare row count, since their hash legitimately varies across runs.
- canon: language tags now join the canonical cell (case-folded), so a
  lang divergence between engines fails the hash gate; a document with
  neither an ASK boolean nor results.bindings errors loudly instead of
  canonicalizing as an empty (blessable) result; the decimal-via-f64
  ~15-significant-digit blind spot is documented in place (exact-decimal
  deferred: it would re-hash every blessed decimal cell).
- spans: iceberg.scan_plan dropped from EXPECTED_FOR_VIRTUAL — it fires
  only on the pruning/pushdown branch (F7), so spans_missing was
  false-flagging most virtual queries; the dashboard column is signal
  again. New rename-guard test pins all 5 allowlist literals to their
  cited engine callsites so a silent engine-side rename can't zero a
  counter.
- cold protocol: exec-one children now inherit the parent run's
  --timeout-s and --cache-dir overrides (previously dropped silently);
  child argv factored out + unit-tested, exec-one grew --timeout-s.
- budgets: a violation now requires the class percent AND a min_delta_ms
  absolute floor (default 50 ms) — 10% of an 8 ms baseline is no longer
  a 0.8 ms tripwire (the exact noise PR-0's validation hit); trade-off
  documented in budgets.json/README.
- bench-support: file-mode BenchSpanLayer no longer pushes to the
  in-memory sink (unbounded growth in a long-running externally-traced
  process with no take() caller); stale 'reserved for BenchSpanLayer'
  doc row corrected; file-only mode unit-tested.
- README refreshed to shipped reality: 54 queries / 20-tag enum /
  16-query smoke, virtual-sf01 ready with committed hot+cold baselines,
  hash_gate + bless-guard + budget-floor semantics, and the
  re-bless-locally protocol for perf gating on a different machine.

Validation: 86/86 crate tests (bench-virtual 33 + bench-support 53);
cargo fmt --all --check clean; clippy denied-lint clean; live exec-one
q001 vs native ok; full 54-query native sweep under the new
canonicalizer reproduces every blessed oracle (45 hash-exact + 9
rows_only row-exact, 0 mismatches).
- q045 appears as 266 ms in the brief and 2.47 s in the diagnosis — both
  real, unlabeled: 266 ms is the warm-process hot median (the committed
  virtual-sf01 baseline), 2.47 s is fresh-process with the REST/catalog
  floor. Each mention now names its cache state; the qualitative claims
  are unchanged.
- ROADMAP harness follow-ups: the F7 scan_plan false-flag is marked
  harness-side DONE (EXPECTED_FOR_VIRTUAL tuned on this branch;
  unconditional engine-side emission stays open), and the stale
  hash_gate compare-side-wiring bullet is struck — it shipped earlier
  on this branch (compare_one gates RowsOnly on rows; bless tolerates
  RowsOnly hash drift).
Base automatically changed from feat/iceberg-virtual-dataset-support to main July 13, 2026 22:12
aaj3f added a commit that referenced this pull request Jul 13, 2026
The #1475 review response added error_boundary_queries_match_observed_behavior
asserting NO corpus query declares virtual=error — true at #1475, but this
PR's manifest deliberately flips q034 (transitive property path) and q051
(subquery) to loud-refuse on virtual (findings F1/F2). After the restack the
base test failed at this branch's HEAD; neither the earlier validation (which
ran fluree-db-query only) nor the review caught it.

Pin the declared-error set to exactly [q034, q051] and assert both stay ok on
native, where the same shapes evaluate fine against the ledger index. The
q043/q044 error-boundary assertions are unchanged.
@aaj3f

aaj3f commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Consolidating at maintainer request. #1475 (the virtual-dataset benchmark corpus, harness, and native-blessed baselines) is carried forward in #1507 (the R2RML/Iceberg virtual-dataset performance program), which brings the #1475–#1507 lineage forward as a single reviewable unit. Its verification of record is the corpus benchmark it introduced, published as C2-bench-wave1.md in the outward-facing audit set (native == virtual, 0 hash mismatches). The pre-consolidation branch tip is preserved at tag archive/pre-refactor-2026-07-21/bench_virtual-dataset-corpus — no history was rewritten. Closing in favor of #1507; discussion continues there.

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