Skip to content
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

Inline symbol-related methods #87

Merged
merged 1 commit into from
Apr 29, 2018
Merged

Inline symbol-related methods #87

merged 1 commit into from
Apr 29, 2018

Conversation

Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Apr 26, 2018

Together with m4b/scroll_derive#6, this significantly improves the performance of SymIterator.

When iterating through an ELF file with 2.5M symbols:
Before: 219ms
After: 120ms

@philipc
Copy link
Collaborator

philipc commented Apr 27, 2018

How did you decide which functions to inline? Inlining functions is fine, just trying to gauge the completeness of this, or whether maybe some of these functions are big enough that maybe they shouldn't be inlined.

@m4b
Copy link
Owner

m4b commented Apr 27, 2018

Yea I don't think this many functions need to be inlined to speed up symbol iteration (probably just the try_from is my guess, taken care of in the scroll PR), e.g., is_import, is_function, size_with, from_raw, etc., shouldn't be need to be inlined

@Amanieu
Copy link
Contributor Author

Amanieu commented Apr 27, 2018

I just marked functions which had a very simple implementation (e.g. is_function) or that can significantly benefit from constant propagation or loop unswitching (e.g. try_from_ctx where the match on Container can be moved out of the hot loop by the compiler).

@@ -468,6 +483,7 @@ if_alloc! {
type Item = <SymIterator<'a> as Iterator>::Item;
type IntoIter = SymIterator<'a>;

#[inline]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is the only one that I don't see any benefit for, since it won't be called often and there's little room for optimization.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method only performs 3 copies and 2 zero-initializations, which are practically free if inlined into the parent function. While you are technically correct that this won't be called often, there is absolutely zero downside to marking it as inline.

Copy link
Collaborator

@philipc philipc left a comment

Choose a reason for hiding this comment

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

Thanks!

@philipc philipc merged commit d83b4ec into m4b:master Apr 29, 2018
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.

None yet

3 participants