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
perf(ngcc): only compute basePaths in TargetedEntryPointFinder when n… #36881
perf(ngcc): only compute basePaths in TargetedEntryPointFinder when n… #36881
Conversation
If I'm not mistaken, wouldn't the |
Agh! |
Hmm. So we have two options, I think:
I think I lean towards 2). WDYT? |
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.
✨
A quick look into Another option would be to revisit the algorithmic complexity of |
FWIW, I would towards option 1 (esp. given that If we wanted to get fancy, we could change |
I've gone with option 1 for now. Let's see how this pans out for @n9niwas's issue. |
@petebacondarwin I applied this change and now it takes 50ms (vs 500ms previously) on average to process each module, so much better, thanks! but I noticed that some modules still take 500ms not sure it's in the scope of this PR, but it would be nice to ignore those too |
If you have packages imported via |
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.
Missed opportunity to go fancy with iterators and generators, but works for me 😄
060ee61
to
58e4e9c
Compare
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.
…eeded Previously the `basePaths` were computed when the finder was instantiated. This was a waste of effort in the case that the targeted entry-point is already processed. This change makes the computation of `basePaths` lazy, so that the work is only done if they are actually needed. Fixes angular#36874
I also did some benchmarking... From randomized paths I found that the average time "per original path" was reduced to about 20% from the original algorithm. |
I am seeing some interesting perf characteristics after the latest fixup: Lastly, always having I would definitely switch back to using |
Are you saying the recursive version is faster? Should we switch back to that version? What are you using to benchmark? |
When I benchmarked again today running the following code 100x on each algorithm:
I got
|
Interesting :-) Here's my results: Map
Record
This is run from a single test in the |
I guess you are on Windows? I wonder if there is some difference there? |
Oh also the only difference between the two algorithms was the use of Map vs Record, right? |
Here's my tweaked setup: https://github.com/JoostK/perf-36881
On my MacBook Pro (late 2013) using NodeJS 10.15.0:
In latest NodeJS (14.1.0) the difference has become smaller:
I'm using a fairly large iteration count as it shows far more stable results. Using a small iteration count, I'm seeing noticeable differences when e.g. swapping the benchmark ordering. Anyway, this is more out of curiosity than it actually making a difference in real life. |
Oh well the differences are minimal on my side. So I'll go with the Map version. |
51091a9
to
b99068c
Compare
This function needs to deduplicate the paths that are found from the paths mappings. Previously this deduplication was not linear and also called the expensive `relative()` function many times. This commit, suggested by @JoostK, reduces the complexity of the deduplication by using a tree structure built from the segments of each path. PR Close #36881
…eeded (#36881) Previously the `basePaths` were computed when the finder was instantiated. This was a waste of effort in the case that the targeted entry-point is already processed. This change makes the computation of `basePaths` lazy, so that the work is only done if they are actually needed. Fixes #36874 PR Close #36881
This function needs to deduplicate the paths that are found from the paths mappings. Previously this deduplication was not linear and also called the expensive `relative()` function many times. This commit, suggested by @JoostK, reduces the complexity of the deduplication by using a tree structure built from the segments of each path. PR Close #36881
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…eeded (angular#36881) Previously the `basePaths` were computed when the finder was instantiated. This was a waste of effort in the case that the targeted entry-point is already processed. This change makes the computation of `basePaths` lazy, so that the work is only done if they are actually needed. Fixes angular#36874 PR Close angular#36881
This function needs to deduplicate the paths that are found from the paths mappings. Previously this deduplication was not linear and also called the expensive `relative()` function many times. This commit, suggested by @JoostK, reduces the complexity of the deduplication by using a tree structure built from the segments of each path. PR Close angular#36881
…eeded
Previously the
basePaths
were computed when the finder was instantiated.This was a waste of effort in the case that the targeted entry-point is already
processed.
This change makes the computation of
basePaths
lazy, so that the work isonly done if they are actually needed.
Fixes #36874