-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 RepoMappingManifestAction #20091
Conversation
The following optimizations reduce the time spent writing the repo mapping manifest from >6s to <80ms for a test referencing each of ~4,000 repos created by a module extension: * The set of repository names appearing in runfiles paths is only constructed once rather than for each repo by moving the `build()` call out of a closure. * The relevant entries per repository are now sorted after filtering out those for repos that don't contribute runfiles. * Crucially, the relevant mapping entries per repository are now cached per instance of `RepositoryMapping#entries()`. Since extension repos all share the same instance due to interning, this reduces the complexity from quadratic to linear in the number of extension repos.
Turns out that the action itself is really fast now, but the key computation is still slow. I will see whether that can be fixed without memory overhead. |
@bazel-io flag |
I pushed a commit that also caches the key computation. The first computation is actually still a bit slower than running the action, but subsequent evaluations are much faster (~1-2ms), leveraging both the nested set fingerprint cache as well as the new repo mapping fingerprint cache. Here is a profile of the reproducing repo (https://github.com/DavidZbarsky-at/repo-mapping-manifest-repro) with |
@bazel-io fork 7.0.0 |
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.
awesome!!
src/main/java/com/google/devtools/build/lib/analysis/RepoMappingManifestAction.java
Outdated
Show resolved
Hide resolved
7684474
to
c6e3efb
Compare
The following optimizations reduce the time spent writing the repo mapping manifest from >6s to <80ms for a test referencing each of ~4,000 repos created by a module extension: * The set of repository names appearing in runfiles paths is only constructed once rather than for each repo by moving the `build()` call out of a closure. * The relevant entries per repository are now sorted after filtering out those for repos that don't contribute runfiles. * Crucially, the relevant mapping entries per repository are now cached per instance of `RepositoryMapping#entries()`. Since extension repos all share the same instance due to interning, this reduces the complexity from quadratic to linear in the number of extension repos. Closes bazelbuild#20091. PiperOrigin-RevId: 581128978 Change-Id: I946e7788b8538e84714cf25ece89a86edd0d6948
The following optimizations reduce the time spent writing the repo mapping manifest from >6s to <80ms for a test referencing each of ~4,000 repos created by a module extension: * The set of repository names appearing in runfiles paths is only constructed once rather than for each repo by moving the `build()` call out of a closure. * The relevant entries per repository are now sorted after filtering out those for repos that don't contribute runfiles. * Crucially, the relevant mapping entries per repository are now cached per instance of `RepositoryMapping#entries()`. Since extension repos all share the same instance due to interning, this reduces the complexity from quadratic to linear in the number of extension repos. Closes #20091. Commit 305ab3b PiperOrigin-RevId: 581128978 Change-Id: I946e7788b8538e84714cf25ece89a86edd0d6948 Co-authored-by: Fabian Meumertzheim <[email protected]>
The changes in this PR have been included in Bazel 7.0.0 RC5. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc. |
The following optimizations reduce the time spent writing the repo mapping manifest from >6s to <80ms for a test referencing each of ~4,000 repos created by a module extension:
build()
call out of a closure.RepositoryMapping#entries()
. Since extension repos all share the same instance due to interning, this reduces the complexity from quadratic to linear in the number of extension repos.