-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Optimize determine_rpath_dirs #14207
base: master
Are you sure you want to change the base?
Conversation
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.
mostly replacing expensive regex with string manipulation.
Can we get effectively the same benefit by checking the prefix and returning early, without rewriting the regex? The code is longer, harder to read and less self-documenting now.
Alternatively what about an lru_cache? This code seems to be run constantly but only have two valid answers: one answer for each for_machine
.
Yeah, there's a lot of cleanup possible here:
|
Thank you for your good suggestions. I will work on it! |
1bcd3d1
to
788a761
Compare
My profile now tells me 3.4 s instead of 9.2 s for the |
When generating targets in ninja backend for my project, `determine_rpath_dirs` is the second most expensive function call. Here are some optimizations: - Use a single regex instead of 3 to find rpath args - Add cache to get_rpath_dirs_from_link_args - Remove unneeded isinstance check for get_external_link_args - early exit when iterating for rpath arguments - compute system_dirs and external_rpaths once per target instead of recomputing them for every link args of the target (!!!)
788a761
to
90c8ff2
Compare
When generating targets in ninja backend for my project,
determine_rpath_dirs
is the second most expensive function call. Here are some optimizations, mostly replacing expensive regex with string manipulation.