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

Prune unneeded transitive dependencies #3395

Merged

Conversation

bruce-richardson
Copy link
Contributor

When getting dependencies, we don't need to get the same dependencies and
dependency chains multiple times. If library a depends on x, y and z, and
library b depends on a, then we should not have to iterate through x, y and
z multiple times. Pruning at the stage of scanning the dependencies leads
to significant time savings when running meson

@bruce-richardson
Copy link
Contributor Author

In terms of performance improvement seen, I've tested this in combination with #3394. That commit reduces my meson runtime from over 10 to just below 9. Adding in this commit reduces the meson runtime on the same test (building dpdk project with all examples) to BELOW 3 seconds! That's approx 3x increase in speed.

@@ -803,12 +803,13 @@ def get_outputs(self):
def get_extra_args(self, language):
return self.extra_args.get(language, [])

def get_dependencies(self):
def get_dependencies(self, exclude=[]):
Copy link
Member

Choose a reason for hiding this comment

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

if t not in transitive_deps and t not in exclude:
transitive_deps.append(t)
if isinstance(t, StaticLibrary):
transitive_deps += t.get_dependencies(transitive_deps + exclude)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: it's easier to read if this is written as:

if t in transitive_deps or t in exclude:
    continue
transitive_deps.append(t)
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thanks. Let me rework. My python is rather rusty.

When getting dependencies, we don't need to get the same dependencies and
dependency chains multiple times. If library a depends on x, y and z, and
library b depends on a, then we should not have to iterate through x, y and
z multiple times. Pruning at the stage of scanning the dependencies leads
to significant time savings when running meson
@bruce-richardson bruce-richardson force-pushed the dependency_optimization branch from 2601ceb to f9a594f Compare April 12, 2018 20:54
@bruce-richardson
Copy link
Contributor Author

reworked following feedback. Performance improvement is now only ~2.5x, which I'm still happy enough about! :-)

@nirbheek
Copy link
Member

reworked following feedback. Performance improvement is now only ~2.5x, which I'm still happy enough about! :-)

Interesting that the kwarg change reduced the performance. Can you try other versions such as using tuples (which are immutable) instead of lists?

@bruce-richardson
Copy link
Contributor Author

hmmm, maybe it didn't. Now that I think about it, I think I may have dropped change #3394 from the tree when I did the later test. It doesn't matter much anyway, it's fast enough for me with this change.

@nirbheek nirbheek added this to the meson-next milestone Apr 13, 2018
@nirbheek nirbheek merged commit c213d71 into mesonbuild:master Apr 13, 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.

2 participants