-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up Trace Statistics view calculation #1941
Speed up Trace Statistics view calculation #1941
Conversation
Resolves jaegertracing#1925 Now we precompute child spans for each span to calculate statistics. Previously we filtered all spans to find children for each span. Signed-off-by: Maksim Gaponov <gaponovmaxev@gmail.com>
packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx
Show resolved
Hide resolved
packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx
Show resolved
Hide resolved
@@ -97,6 +107,7 @@ function valueFirstDropdown(selectedTagKey: string, trace: Trace) { | |||
let color = ''; | |||
let allDiffColumnValues = []; | |||
const allSpans = trace.spans; | |||
parentChildOfMap = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you keep nulling this out?
span.childSpanIds.includes(each.spanID) && | ||
each.references[0].spanID === span.spanID && | ||
each.references[0].refType === 'CHILD_OF' | ||
const cdr = new DRange(span.startTime, span.startTime + span.duration - 1).intersect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep the original logic parent.subtract(children)
. Your change does not require modifying that logic since all you need to do is cache children mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Maksim Gaponov <gaponovmaxev@gmail.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1941 +/- ##
=======================================
Coverage 96.54% 96.54%
=======================================
Files 256 256
Lines 7604 7613 +9
Branches 1978 1978
=======================================
+ Hits 7341 7350 +9
Misses 263 263 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Maksim Gaponov <gaponovmaxev@gmail.com>
Seems like everything is fixed. Can you please review it again? @yurishkuro |
each.references[0].spanID === span.spanID && | ||
each.references[0].refType === 'CHILD_OF' | ||
if (!span.hasChildren) return span.duration; | ||
const spanRange = new DRange(span.startTime, span.startTime + span.duration - 1).subtract( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can change the logic away from *10
. DRange does not work correctly on the raw timestamps (see the comments above).
Side note: we need a test that illustrates that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the calculations need to change - the speed-up is coming from building a map once instead of n^2 looping, so why not change just that part and leave the calculations intact?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the change we use DRange(begin, end - 1)
to represent halp-open intervals. The length of this DRange is (end-1)-begin+1=end-begin
because DRange treats all intervals as inclusive.
In the example above (1, 10)
will be represented as DRange(1, 9)
; (4, 8)
will be represented as DRange(4, 7)
. So first.substract(second)
will be range([1..3], [8..9])
(length = 3+2=5
).
As I understand there is a mistake in the comment in the calculation of Drange.length
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That still doesn't answer my question why calculations need to change, it a PR that is about efficiency of the code.
If you want to dig down to the exact reasons for *10 logic, you can see the comment as well as the discussion on the original PR that introduced it. TLDR is that DRange does not understand open/close intervals, and subtraction works incorrectly for our purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. It shouldn't be changed in this PR. Returned to the initial version.
Signed-off-by: Maksim Gaponov <gaponovmaxev@gmail.com>
packages/jaeger-ui/src/components/TracePage/TraceStatistics/tableValues.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com> Signed-off-by: Maksim <gaponovmaxev@gmail.com>
Signed-off-by: Maksim Gaponov <gaponovmaxev@gmail.com>
Signed-off-by: Yuri Shkuro <github@ysh.us>
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:yarn lint
andyarn test