web-console: anchor performance graph time axis to server time#6455
web-console: anchor performance graph time axis to server time#6455Karakatiza666 wants to merge 1 commit into
Conversation
The throughput, memory, and storage graphs computed their x-axis domain from the client clock (`Date.now()`), but every sample is stamped with server time. Any client/server clock skew shifted the plotted line relative to the axis, so the graphs under-filled the width and the line appeared to shrink over the first ~30s. Anchor the axis to the newest sample's timestamp (falling back to the server-time estimate via `dateNow()` before data arrives) so the newest point always sits at the right edge and the window spans the full keep interval, regardless of clock skew. Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
|
|
||
| // Anchor the time axis to the newest sample's timestamp rather than to the | ||
| // client clock. | ||
| const xAxisMax = $derived(metrics.at(-1)?.t.toNumber() ?? dateNow()) |
There was a problem hiding this comment.
Rename dateNow to inferredServerNow or something like this.
This name is very confusing.
I wonder what happens if you disconnect from the server for a long time but keep the window open.
mythical-fred
left a comment
There was a problem hiding this comment.
The fix is correct — anchoring to the newest sample's server timestamp rather than Date.now() eliminates the client/server clock skew problem cleanly. Good commit message too.
However, this is a behavior change in web-console code and ships without tests. Per our hard rule, behavior changes in js-packages/web-console/ require at least a unit test. Even a Vitest test that verifies xAxisMax is derived from the last sample's timestamp (and falls back to dateNow() when no samples exist) would satisfy this.
The throughput, memory, and storage graphs computed the x-axis timestamps from the client clock (
Date.now()), but every sample is stamped with server time. Any client/server clock difference shifted the plotted line relative to the axis, so in these cases the graphs under-filled the width.This PR adjusts the time span of the graph based on the server clock (existing mechanism to sync to server time), not client time.
Fix #5721