Repository navigation
feat(zero-swift): inspector, query metrics, and slowMaterializeThreshold - #210
Merged
Merged
Conversation
…reshold zero.inspector ports @rocicorp/zero's Inspector over the sync connection's inspect messages. Where JS prompts for the admin password, a request throws InspectorError.authenticationRequired until authenticate(password:) succeeds; the accepted password is presented again on an unauthenticated later connection. The client records JS's query metrics in a port of shared/src/tdigest.ts, with fdlibm's asin and sin so its quantiles match Node's bit for bit, and ZeroOptions.slowMaterializeThreshold logs slow end-to-end materializations.
…rs check TDigest.quantile returns NaN, as JS does, where rounding leaves the last cumulative weight below the total, instead of trapping. The connect URL asks for debugPerf at the debug log level, as JS and Rust do. An inspector query's inactivatedAt is new Date(ms)'s time value, without its fraction.
tmm
force-pushed
the
feat/zero-swift-inspector
branch
from
November 14, 2026 12:36
581f934 to
1541981
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decision 3, Swift half: JS's inspector, query metrics, and
slowMaterializeThresholdin zero-swift, lined up with the Rust port (next PR). Stacked on #206;zero-swiftpatch changeset, as earlier Swift feature changesets are.Same shape as Rust's
zero.inspector():metrics,client/clientGroup(queries,map,rows,clients,clientsWithQueries),serverVersion,analyzeQuery/analyzeServerAST/analyzeNamedQuery,authenticate,formatPlannerEvents;Metricsof fiveTDigests; typedInspectorQueryandAnalyzeQueryResult.How it differs from JS, as Rust does:
InspectorError.authenticationRequired;authenticate(password:)remembers an accepted password and presents it again after a reconnect, in JS's wire order.close()instead of waiting forever.<message> <queryID> <AST JSON> <ms>.TDigestmatches JS bit for bit: V8's fdlibmasin/sinare ported, since glibc's differ in the last bit and move centroid splits (checked on 846,739 inputs and 400 seeded JS digests).Metrics are recorded where JS calls
addMetric; updates are sampled 1 in 32 and weighted 32 (UPDATE_SAMPLE_RATE).Tests:
TDigestTests(7) andInspectorTests(13), with expected values from running the repo's JS sources. Locally:swift format lint --strict,ZeroTests160 passed,ConformanceTests63 passed, docs build, andscripts/api-breaks.sh: no public API breaks since 0.7.12. The Rust PR adds the shared JS vectors (client-inspector.json,tdigest.json,ast-to-zql.json, andlogsin two existing ones), and Swift's conformance runner replays them there.