Commit 53eddaf
Optimize SequenceGlob matching performance using a Set.
When `origin_files` is provided as a list of files, Copybara uses `SequenceGlob`.
Previously, `SequenceGlob.relativeTo` returned a `PathMatcher` that iterated linearly through all files in the list for every file checked during checkout. This resulted in O(N*M) complexity where N is the number of files in the list and M is the number of files checked.
This change optimizes `SequenceGlob` to pre-calculate the relative paths and store them in an `ImmutableSet`. This allows for O(1) lookup time during matching, reducing the complexity to O(N + M).
Benchmarks show a ~73x speedup in matching time for 5000 files (1589ms -> 21ms).
BUG=467397947
GWSQ_IGNORE: chriscampos@google.com
PiperOrigin-RevId: 847778127
Change-Id: Idaf21e5773faa3d61ce3c9a07ac0d1524df1c0f51 parent 79c21be commit 53eddaf
1 file changed
+32
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
21 | 19 | | |
| 20 | + | |
22 | 21 | | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
44 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
45 | 59 | | |
46 | 60 | | |
47 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
48 | 75 | | |
49 | 76 | | |
50 | 77 | | |
| |||
0 commit comments