-
Notifications
You must be signed in to change notification settings - Fork 63
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
Improve performance by parsing function contents lazily #178
Conversation
You can use |
We previously had no clean way of indicating that there were no frames, and this would have become harder to support for future changes. Co-authored-by: Markus Stange <[email protected]>
d50cb93
to
8789de0
Compare
I'm reviewing this now. |
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.
Looks great! Just one or two comments that need adjusting for the different variable names.
Thanks!
.as_ref() | ||
.map_err(Error::clone) | ||
.map_err(Error::clone)? |
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.
Oh good, this is better than what I did because you store the error, rather than re-parsing errored functions on every call.
gimli::DW_TAG_subprogram => { | ||
Function::skip(entries, abbrev, next_depth)?; | ||
} |
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.
Interesting. Yeah, I think you're handling this more correctly than I was. I think my PR was siphoning inlines from nested subprograms into the outer subprogram.
And use only a single list of inlined function addresses per function. This reduces the overall number of allocations, and will allow lazy parsing of inlined functions in future. Since we now need to search through a larger list, we must use a binary search to retain query performance. Co-authored-by: Markus Stange <[email protected]>
Co-authored-by: Markus Stange <[email protected]>
Currently the same as function parsing.
Initially only parse the function address ranges. Delay parsing other details (name and inlined functions) until a probe matches. name before ns/iter after ns/iter diff ns/iter diff % speedup context_new_and_query_location_rc 3,289,458 2,797,820 -491,638 -14.95% x 1.18 context_new_and_query_location_slice 1,387,033 1,092,108 -294,925 -21.26% x 1.27 context_new_and_query_with_functions_rc 3,247,986 2,864,962 -383,024 -11.79% x 1.13 context_new_and_query_with_functions_slice 1,423,648 1,085,133 -338,515 -23.78% x 1.31 context_new_parse_functions_rc 53,668,984 23,596,242 -30,072,742 -56.03% x 2.27 context_new_parse_functions_slice 40,013,306 18,342,944 -21,670,362 -54.16% x 2.18 context_new_parse_inlined_functions_rc 54,060,518 53,382,830 -677,688 -1.25% x 1.01 context_new_parse_inlined_functions_slice 40,016,318 40,217,181 200,863 0.50% x 1.00 context_new_parse_lines_rc 12,129,688 11,873,223 -256,465 -2.11% x 1.02 context_new_parse_lines_slice 7,494,676 7,534,801 40,125 0.54% x 0.99 context_new_rc 2,304,944 2,365,795 60,851 2.64% x 0.97 context_new_slice 696,658 681,423 -15,235 -2.19% x 1.02 context_query_location_rc 1,034,087 1,004,797 -29,290 -2.83% x 1.03 context_query_location_slice 997,554 986,323 -11,231 -1.13% x 1.01 context_query_with_functions_rc 3,167,282 3,233,303 66,021 2.08% x 0.98 context_query_with_functions_slice 2,865,103 2,839,624 -25,479 -0.89% x 1.01 Co-authored-by: Markus Stange <[email protected]>
This is a significant rebase of the great work done by @mstange in #176 . Closes #176 .
The description from that PR still applies:
Differences from that PR:
LazyCell
instead ofRc
/RefCell
, since this makes the code easier to understandThis PR was written by completely rewriting the commits instead of doing a normal rebase. Hopefully I haven't left out anything significant.
@mstange Could you please review this, and check against the benchmarks you were using? And thanks again for your work on this.