-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Further --changed optimization (#5579)
### Problem A few more performance issues were discovered in `./pants --changed=.. list` due to the removal of the v1 engine: * In order to calculate `direct` or `transitive` dependents, `ChangeCalculator` needs to compute the dependents graph. But it was doing this using `HydratedTargets` (ie, with sources globs and other fields expanded). * After the `ChangeCalculator` was used to compute the new set of `TargetRoots`, we were converting the matched `Address` objects back into `Spec`s, triggering #4533. * When locating candidate owning targets for some sources, `SourceMapper` was using `HydratedTargets`, which are (implicitly/unnecessarily) transitive. * When matching source files against candidate targets, `SourceMapper` was using un-batched regex-based spec matching calls. ### Solution * Add and switch to computing `HydratedStructs` in `ChangeCalculator`, which do not require expanding sources globs. * Rename `HydratedTargets` to `TransitiveHydratedTargets`, and add a non-transitive rule to compute `HydratedTargets`. Use this in `SourceMapper`. * Preserve `Address` objects in `ChangedTargetRoots`, which allows for a single deduped `TransitiveHydratedTarget` walk to warm and populate the graph. * Add and used batched forms of the `filespec` matching methods to avoid re-parsing/compiling regexes. These matches should be ported to rust at some point. ### Result Transitive runs that touch more of the graph take time closer to the `./pants list ::` time, as expected. Before: ``` $ time ./pants --changed-diffspec=22ca0604b1c6ce8de019214b821e922aac66b026^..22ca060 --changed-include-dependees=transitive list | wc -l 562 real 0m15.945s user 0m15.180s sys 0m1.731s ``` After: ``` $ time ./pants --changed-diffspec=22ca0604b1c6ce8de019214b821e922aac66b026^..22ca060 --changed-include-dependees=transitive list | wc -l 563 real 0m5.402s user 0m4.580s sys 0m1.319s ``` Larger runs (more files/targets) see an even more significant speedup: on the order of 5-10x.
- Loading branch information
Stu Hood
authored
Mar 14, 2018
1 parent
68ce613
commit c981c39
Showing
19 changed files
with
246 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding=utf-8 | ||
# Copyright 2016 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
from pants.util.objects import datatype | ||
|
||
|
||
class InvalidSpecConstraint(Exception): | ||
"""Raised when invalid constraints are given via target specs and arguments like --changed*.""" | ||
|
||
|
||
class TargetRoots(object): | ||
"""Determines the target roots for a given pants run.""" | ||
|
||
|
||
class ChangedTargetRoots(datatype('ChangedTargetRoots', ['addresses']), TargetRoots): | ||
"""Target roots that have been altered by `--changed` functionality. | ||
Contains a list of `Address`es rather than `Spec`s, because all inputs have already been | ||
resolved, and are known to exist. | ||
""" | ||
|
||
|
||
class LiteralTargetRoots(datatype('LiteralTargetRoots', ['specs']), TargetRoots): | ||
"""User defined target roots, as pants.base.specs.Spec objects.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.