Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Speed up search by using parallel Glob and Binary Search for including files checks#1122

Merged
yonaskolb merged 2 commits intoyonaskolb:masterfrom
MacPaw:fix/faster-include-checks
Oct 7, 2021
Merged

Speed up search by using parallel Glob and Binary Search for including files checks#1122
yonaskolb merged 2 commits intoyonaskolb:masterfrom
MacPaw:fix/faster-include-checks

Conversation

@PaulTaykalo
Copy link
Contributor

@PaulTaykalo PaulTaykalo commented Sep 9, 2021

Binary Search in checking if file if contained in included paths

in this PR, instead of checking if each file contains the paths, we're using binary search.
This PR speed ups checks, especially in cases when multiple files are added (i.e few thousand)

Before this PR, the complexity of checking if a file is included is O(N * M) where N - files to check, M - included files

This PR will decrease complexity to O(N * log(M)) which significantly improves operations on big projects.

Parallel calls of Glob invocations

This PR adds a parallel call of glob invocations, since calling those in one thread and waiting for the results will take lead to enormous waste.

By adding these two changes, one can achieve significant speedup, especially on relatively big projects###

Before

image
image

After

image
image

@PaulTaykalo PaulTaykalo force-pushed the fix/faster-include-checks branch from 967f290 to 8c20a3b Compare September 9, 2021 21:20
@PaulTaykalo PaulTaykalo changed the title Use binary search for Checking if path is included in included files Speed up search by using parallel Glob and Binary Search for including files checks Sep 9, 2021
@PaulTaykalo
Copy link
Contributor Author

@yonaskolb is there something I can help in order this PR to be merged in?

Copy link
Owner

@yonaskolb yonaskolb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @PaulTaykalo! Do you have examples of before and afters in a large project?
Could you please add a changeling entry as well

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add some tests for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@PaulTaykalo PaulTaykalo force-pushed the fix/faster-include-checks branch from 8c20a3b to fcdb276 Compare October 4, 2021 22:56
@PaulTaykalo PaulTaykalo requested a review from yonaskolb October 4, 2021 22:59
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another thing the SortedArray does is sort the elements it's initialised with if we could test that too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@yonaskolb
Copy link
Owner

@keith are you still using this at Lyft? Would be great to see the results on your project, as it's the biggest I've heard of

@PaulTaykalo PaulTaykalo force-pushed the fix/faster-include-checks branch from fcdb276 to 69353e0 Compare October 4, 2021 23:46
@PaulTaykalo PaulTaykalo requested a review from yonaskolb October 4, 2021 23:49
@namolnad
Copy link
Contributor

namolnad commented Oct 5, 2021

@keith are you still using this at Lyft? Would be great to see the results on your project, as it's the biggest I've heard of

I tested this out for the Instacart project and saw some modest gains. From around 11.64 seconds -> 11.3 seconds — certainly a move in the right direction, but perhaps not an example of the massive gains you may see elsewhere.

@keith
Copy link
Collaborator

keith commented Oct 5, 2021

Here's some tests with a very large configuration for us:

master xcodegen:

  Time (mean ± σ):     42.438 s ±  4.635 s    [User: 64.061 s, System: 4.952 s]
  Range (min … max):   36.565 s … 49.839 s    10 runs

changed xcodegen:

  Time (mean ± σ):     40.603 s ±  2.978 s    [User: 62.073 s, System: 4.567 s]
  Range (min … max):   36.873 s … 44.839 s    10 runs

so this definitely helps a bit, but maybe this just isn't a path we're hurt much by

@PaulTaykalo
Copy link
Contributor Author

@keith it seems that your case is - many configurations, many small projects. Am I right?
My case is more like - few configurations, heavy projects (over 200-1000+ files).

@keith
Copy link
Collaborator

keith commented Oct 6, 2021

This test was 1 project, 2 configurations, a few thousand targets, tens of thousands of files

@PaulTaykalo
Copy link
Contributor Author

PaulTaykalo commented Oct 6, 2021

This test was 1 project, 2 configurations, a few thousand targets, tens of thousands of files

😳 Wondering what was is so different in my case.
The only thing I can think of is that your projects should have a relatively flat structure, while mine has a pretty deep hierarchy. 🤔

Copy link
Owner

@yonaskolb yonaskolb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks @PaulTaykalo!

@yonaskolb yonaskolb merged commit 10fb431 into yonaskolb:master Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants