-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Avoid no-op export map updates #45238
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
...so that unchanged maps can be recognized without having to examine their contents.
In practice, `updateExportedFilesMapFromCache` is called repeatedly without the cache changing in between. When this occurs, there's no need to update the `BuilderState` (this was already the net effect, but it took a long time to determine that no work was required).
For my local repro 4.2: 631.23s |
@DanielRosenwasser @RyanCavanaugh I think it's important to get this into 4.4 because I don't have a good sense of whether/which real world scenarios will see the large build time regression I noticed in my (contrived) local experiments. |
addToMultimap(reverse, v, k); | ||
} | ||
}); | ||
|
||
if (changed) { | ||
version++; |
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.
It's vitally important that this not miss a case where the map has actually changed - please double-check.
@typescript-bot perf test this |
Heya @amcasey, I've started to run the perf test suite on this PR at 03bfca3. You can monitor the build here. Update: The results are in! |
As far as I know, the perf suite doesn't cover build mode, so I don't expect any changes. Edit: confirmed |
@amcasey Here they are:Comparison Report - main..45238
System
Hosts
Scenarios
Developer Information: |
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.
Seems fine to me, though there is some feedback you might want to consider. You should get a second look from @andrewbranch.
This reverts commit 0f6e6ef.
This reverts commit 0f6e6ef.
This reverts commit 0f6e6ef.
This reverts commit 0f6e6ef.
This reverts commit 0f6e6ef.
This reverts commit 0f6e6ef.
…cache. (microsoft#48579) * Revert "Avoid no-op export map updates (microsoft#45238)" This reverts commit 0f6e6ef. * Need to reset currentAffectedFilesExportedModulesMap after commiting to final exports map
This is a follow-up to #44402. Internal teams with large projects have seen significant perf wins from that change (~20% reduction in build time) but I've stumbled onto some pathological cases where the change actually increases build time by ~50%.
The builder maintains two copies of the exported modules map - changes are accumulated in a copy so that they can be discarded if something invalidated the update. When the build does complete successfully, one
ManyToManyPathMap
is updated from another, which requires traversing both. In local measurements, each such update was taking 2-4 seconds (this is very project-specific) and there were 2000 in the course of building a single project. However, it turned out that the copy was never actually modified after its initialization, so all subsequent updates of the "real" map were no-ops. This change introduces a cheap way to determine that the cache hasn't changed.I think we could probably use a more sophisticated method to handle these updates (e.g. accumulating only a delta), but I deliberately made the change very simple because we're so late in the 4.4 cycle.