Skip to content

feat(zero-rust): inspector, query metrics, and slowMaterializeThreshold - #211

Merged
tmm merged 2 commits into
mainfrom
feat/zero-rust-inspector
Nov 14, 2026
Merged

tmm merged 2 commits into
mainfrom
feat/zero-rust-inspector

Conversation

@tmm

@tmm tmm commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Decision 3, Rust half: JS's inspector, query metrics, and slowMaterializeThreshold in zero-client, lined up with the Swift port (#210). zero-rust minor changeset, so it rides with 0.2.0.

Swift's half merged as #210; this adds the Rust port, the shared JS vectors, and Swift's replay of them.

let opts = ZeroOptions { slow_materialize_threshold_ms: 5_000.0, ..Default::default() }; // JS default
let insp = zero.inspector();
insp.metrics();                      // client TDigests merged with the server's
insp.client().queries();             // ZQL, row counts, hydrate/update timings
insp.clients_with_queries();
insp.server_version();
insp.analyze_query(&ISSUE_LIST_V2.with(args), AnalyzeQueryOptions { join_plans: Some(true), ..Default::default() });
insp.authenticate("password");

Rust (feat(zero-rust) commit)

  • client::{Inspector, InspectorClient, InspectorClientGroup, InspectorQuery, Metrics, AnalyzeQueryOptions, AnalyzeQueryResult, PlanDebugEvent}, tdigest::TDigest, ast::ast_to_zql. Calls return Deferreds.
  • Metrics are recorded where JS calls addMetric. A MeasurePush operator times 1 push in 32, weighted 32 (UPDATE_SAMPLE_RATE); reconciles that reach a view aren't timed, as in JS. Evicted queries are kept once an inspector exists. debugPerf is sent at the debug log level.
  • Differences from JS, the same as Swift's and documented in PARITY.md's new "The inspector" section:
    • There's no password dialog. A refused request fails until authenticate(password) is called, and an accepted password is presented again after a reconnect.
    • Pending requests fail on a dropped connection or close() instead of hanging.
    • The slow-materialization log is one line.
  • Default build: still no third-party dependencies.

Vectors (JS-generated)

  • tdigest.json (72), ast-to-zql.json (101), and client-inspector.json (12 scenarios).
  • harness.ts gains inspect steps, the inspector and logs observations, and the slowMaterializeThreshold and logLevel options. The logs observation adds expected warnings to client-harden-mutations.json and harden-queries.json.

Swift (test(zero-swift) commit)

Checked locally

  • Rust: cargo clippy --workspace --all-targets --all-features -D warnings, cargo test --workspace --all-features, and cargo doc -D warnings.
  • Conformance: 66,370 cases, 0 failures, with the same 2,255 documented exceptions as before. The new files pass 101/101, 72/72, and 12/12 on memory and SQLite.
  • Swift: swift format lint --strict, and ConformanceTests with 67 tests passing, client-inspector 12/12 on memory and SQLite.
  • JS: pnpm --filter zero-conformance run test passes 265, and the vectors are unchanged afterwards.
  • Benchmarks, base vs branch alternating: materialize, put, and optimistic update are within ±7% in both directions. Round trip first read +17%/+19%; 6 more alternating rounds put it at +1.6%/+3.7%/+2.2% with overlapping ranges, which is noise.

@tmm
tmm force-pushed the feat/zero-rust-define branch from 43688aa to 7c2887f Compare November 14, 2026 12:36
@tmm
tmm force-pushed the feat/zero-rust-inspector branch from 862dc4a to a73017e Compare November 14, 2026 12:36
Base automatically changed from feat/zero-rust-define to main November 14, 2026 13:51
@tmm
tmm force-pushed the feat/zero-rust-inspector branch from a73017e to 02111df Compare November 14, 2026 13:52
Port @rocicorp/zero's inspector to the Rust client: Zero::inspector()
lists the local clients and their queries, reads a client's map and rows,
and runs the metrics, version, analyze-query, and authenticate RPCs over
the socket's inspect messages. The client records JS's query metrics as
TDigests (a port of shared/src/tdigest.ts), logs each query's end-to-end
materialization against the new slow_materialize_threshold_ms, and ports
astToZQL and formatPlannerEvents.

Add JS-generated vectors for TDigest, astToZQL, and client inspector
scenarios, and replay them in the Rust conformance runner.
…ectors

The client scenario runner follows harness.ts: the logLevel option, the
logs observation (the materialization messages Swift logs as one line,
parsed back into JS's arguments), and inspect steps with the inspector
observation and $inspect.<n> request IDs. client-inspector.json runs on
memory and SQLite; tdigest.json and ast-to-zql.json (its unredacted code;
Swift has no redactLiterals) replay in the primitive and AST suites.
@tmm
tmm force-pushed the feat/zero-rust-inspector branch from 02111df to e2a0980 Compare November 14, 2026 14:47
@tmm
tmm merged commit 16ee0b8 into main Nov 14, 2026
24 checks passed
@tmm
tmm deleted the feat/zero-rust-inspector branch November 14, 2026 15:40
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.

2 participants