Skip to content

web-console: anchor performance graph time axis to server time#6455

Open
Karakatiza666 wants to merge 1 commit into
mainfrom
issue5721
Open

web-console: anchor performance graph time axis to server time#6455
Karakatiza666 wants to merge 1 commit into
mainfrom
issue5721

Conversation

@Karakatiza666

Copy link
Copy Markdown
Contributor

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

@Karakatiza666 Karakatiza666 requested a review from mihaibudiu June 11, 2026 22:20
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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mythical-fred left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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.

Web console graphs sometimes only use half the space

3 participants