feat: per-phase query latency breakdown in the frame header#415
Open
shaunpatterson wants to merge 5 commits into
Open
feat: per-phase query latency breakdown in the frame header#415shaunpatterson wants to merge 5 commits into
shaunpatterson wants to merge 5 commits into
Conversation
Dgraph returns a per-phase latency breakdown with every response (extensions.server_latency: parsing/processing/encoding/...), but Ratel discarded it - and the frame header latency bar was dead code: it read frame.serverLatencyNs while the timing lives on frameResults[id][tab], so it never rendered at all. - lib/latency.js: pure helpers turning server_latency into ordered, labelled bar segments (known phases in pipeline order, unknown *_ns fields included future-proof, total_ns excluded) plus tooltip text. 9 unit tests. - frames reducer keeps the raw server_latency on the frame result. - FrameHeader now receives tabResult and renders a multi-segment color-coded bar (parsing/processing/encoding/network) with a per-phase tooltip showing times and percentages. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Address review feedback on the latency bar: - The collapsed headline now shows the grand total (server phases + network), not parsing+processing+encoding, matching what users expect from "total". - Clicking the latency bar opens a 'Query latency breakdown' modal (the hover tooltip is kept) with one labelled, colored bar per phase plus a total row. - A 'Num UIDs' section counts the values each predicate contributed to the response (scalars once, child lists by length), a proxy for how much data the query returned and thus its processing/encoding/network cost. countPredicates/numUidSegments are pure and unit-tested. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
Contributor
Author
Per review, the Latency section now reads as a sequence over the total query duration: each phase bar starts where the previous phase ended (offset by cumulative elapsed time) instead of every bar starting at zero. Num UIDs bars stay left-aligned as plain counts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The modal chrome is themed centrally, but the latency/num-uids bar tracks rendered bright white and labels were dim in dark mode. Add [data-theme=dark] overrides (co-located with the component) so the empty tracks use the dark elevated surface, the total rule/border use the dark border, and labels/values stay legible. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The 120px label column truncated 'Assign timestamp' to 'Assign timesta...'. Widen to 150px so the longest phase label fits without ellipsis. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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
Dgraph returns a per-phase latency breakdown with every response (
extensions.server_latency: parsing / processing / encoding / …) but Ratel discarded it. This PR surfaces it as a color-coded multi-segment bar in the frame header with a per-phase tooltip (time + percentage per phase, plus network time and total).Also fixes a latent bug
The existing frame-header latency bar was dead code: it read
frame.serverLatencyNs, but the timing has always been stored onframeResults[frameId][tab]— so the bar never rendered at all. FrameHeader now receives the tab result and renders from it.How
lib/latency.js— pure helpers turningserver_latencyinto ordered, labelled segments: known phases in pipeline order (parsing → processing → encoding → assign timestamp), unknown*_nsfields the server may add later included with prettified labels (future-proof),total_nsexcluded as redundant. 9 unit tests.server_latencyobject on the frame result (alongside the existing summed fields).FrameHeader.scss.Testing
9 unit tests across formatting, segment ordering, zero-skipping, unknown-phase inclusion, ratio math and tooltip text.
npm run buildpasses.🤖 Generated with Claude Code