Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Switch to bespoke attribute name iterator to improve --experimental_e…
…xisting_rules_immutable_view performance The initial implementation of https://github.com/bazelbuild/proposals/blob/main/designs/2021-06-15-improving-native.existing_rules.md was a performance win in most scenarios, but with one notable exception: it was slower on packages with "deep iteration" (a package that repeatedly calls `native.existing_rules` to examine every rule name, every attribute name, and every attribute value). To my surprise, profiler results showed that most of the slowdown came from iterating rule attribute names in ExistingRuleView - specifically, from the stream().map(...).filter(...).iterator() construction. Switching to a bespoke iterator improves performance considerably. Mean loading phase wall times for a 4000-target package with "deep iteration": * --noexperimental_existing_rules_immutable_view: 45.85 s * --experimental_existing_rules_immutable_view before this change: 52.77 s * --experimental_existing_rules_immutable_view after this change: 44.86 s With this change, `--experimental_existing_rules_immutable_view` should be a performance win in all situations. PiperOrigin-RevId: 401629667
- Loading branch information