feat: run results report CPU time and per-call bridge records from the runtime - #40
Merged
Conversation
…e runtime Every RunResult now carries cpuTimeMs (active V8 execution, bridge waits excluded — durationMs stays wall-clock) and bridgeCalls: one metadata record per bridge call attempt, recorded inside the Rust runtime on the run's own clock. Records carry the resolved name, start offset, round-trip duration, argument/response byte sizes, and outcome; attempts blocked by maxBridgeCalls/maxBridgeCallBytes are included with blocked: true. Payloads are never captured. The TS client only decodes and maps wire-level stub names to public names (__iso4_call + handle → specifier.path, shim stubs → public name) — measurement lives runtime-side so any client gets the same data. Aborted runs report zeros and an empty list for now: the abort teardown precedes the runtime's result frame. Graceful termination (#36) will close that gap.
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.
What
Every
RunResult(completed / failed / aborted) now reports what the run actually did, measured inside the Rust runtime:<specifier>.<path>(e.g.tools:search.query).maxBridgeCalls/maxBridgeCallBytes/function-argument checks get a record withblocked: true— they never reached the host, but the report shows exactly which attempt crossed the limit.durationMs, so entries line up on a timeline;durationMs − cpuTimeMs ≈bridge waits + scheduling.Where the data comes from
Recording lives in the Rust runtime (bridge callback records the attempt; the poll loop settles it when the response frame returns). The TS client only decodes the Result frame and maps wire-level stub names to public names — the client measures nothing.
cpuTimeMsreads the existing CPU budget through a new µs-resolution accessor (the integer-ms one only fed the 10ms guard and would report 0 for sub-ms runs).Wire: result frames gain
f64 cpuTimeMs+List<BridgeCallRecord>(~40 bytes/record);docs/protocol.md§5.6 documents the layout.Known gap
Aborted runs report
cpuTimeMs: 0andbridgeCalls: []— the abort tears the connection down before the runtime can send its result frame. Tracked in #36 (graceful terminate), which matters most for durable-isolates suspensions.Testing
cpuTimeMsexcludes a 150ms handler wait, shim + import name resolution, handler errors (ok: false), failed runs keep the report, blocked entries at the limit, aborted-empty,prefix.run().cargo fmt, eslint clean on changed files.