-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Call stack perf change for CallerInfo #1614
base: master
Are you sure you want to change the base?
Call stack perf change for CallerInfo #1614
Conversation
assert/assertions.go
Outdated
if more { | ||
continue | ||
} | ||
// We know we already have less than a buffer's worth of frames | ||
if !maybeMore { | ||
break | ||
} | ||
offset += stackFrameBufferSize | ||
n = runtime.Callers(offset, pcs) | ||
if n == 0 { | ||
break | ||
} | ||
|
||
maybeMore = n == stackFrameBufferSize |
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.
Copying this comment from #1615 which also contains this change.
I'm not a fan of more
and maybeMore
, this code is actually two nested loops and I think it would be more readable if you coded it that way. I think that pure behaviour is usually better than data (varibles) used only to alter behaviour.
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 just pushed a commit that moves this to two loops (though still using more
to break
out of the inner loop). LMK if that's along the lines of what you were thinking.
The performance enhancement in this code is a change I'd be happy to include, with some slight alteration. |
Summary
CallerInfo
to useruntime.Callers()
to pull the stack instead of repeatedly callingruntime.Caller()
Changes
Callers()
instead of repeatedCaller
invocations, because there is a cost to querying the stackframes.Next()
iteratorMotivation
Caller
contributing a CPU cost of 7660ms out of a total cost of 13740msRelated issues