-
Notifications
You must be signed in to change notification settings - Fork 12
feat: add memoization when converting tree to graph #74
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
Conversation
36a2848
to
d842c25
Compare
Like with the other PR, this appears to just leak memory forever, unless we're planning to use it perfectly in all cases. Isn't there some kind of |
https://github.com/dominictarr/bench-lru if you do go that route |
@FauxFaux I don't think either of the PRs leak memory. In both cases GC will clean up the maps themselves at some point after the operation is complete. Also, the values/keys in the maps are already in memory and shared by the output instances. What are you seeing that I'm not? Also, I don'r see how an |
I WAS WRONG IGNORE ME. |
For posterity: the concern was around how default argument initialisers are evaluated in JS (versus Python, for example, where this would indeed be problematic) |
🎉 This PR is included in version 1.22.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
because in Python arguments with a mutable default value get attached to the function as a "private member" and never get deleted? so the concern was |
Hey all, Sorry to revive an old-ish thread but I tried this PR and it did not improve the performance of
never evaluated to true because
so I'm wondering whether the behavior in this PR was intentional. |
Hi @calvinli . Apologies for the delay.
Yep, unfortunately that was intentional - this was just a small optimisation following on from #73 so it only helps in that particular case. Some tools (like
Your change would consider both instances of Having to compare sub trees like this makes the conversion very expensive indeed. The goal is to build dep-graphs directly (instead of trees) so that we can avoid this issue entirely. |
What does this PR do?
Like #73 (which affects graphToDepTree), It adds memoization in the depTreeToGraph
For a very large tree (that was generated using the memoization from #73), it reduced the time from 20000ms to less than 200ms