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
Improve tuist generate
speed by caching Swift version fetching
#2546
Conversation
36cfbc5
to
3671bd6
Compare
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.
Nice! Thank you for contributing 🚀
@@ -585,17 +585,23 @@ public final class System: Systeming { | |||
try process.launch() | |||
} | |||
|
|||
var cachedSwiftVersion: String? |
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.
You might want to add some locks to prevent race conditions when accessing it from multiple threads
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.
Nice catch, done! I noticed we have Atomic property wrapper in Tuist Support, that should do the work :)
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.
To help stress test this you could try generating a fixture with 50 projects :)
f3e93ef
to
7b5bb1f
Compare
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.
This is great to see, thanks!
Short description 📝
Hello,
Currently every time a Target is generated we try to fetch what Swift version we have on the system.
This is an expensive operation since we need to execute an external shell command.
The impact can be easily seen when having a good number of targets.
In my tests, I've got
tuist generate
(release mode) to run from 20s to 13s, a nice 40% of improvement!Update: got similar (or even better) results using
tuistbenchmark
for an existing fixture:and for a generated fixture: (
fixturegen --projects 2 --targets 50 --sources 50
):Checklist ✅
CHANGELOG.md
has been updated to reflect the changes. In case of a breaking change, it's been flagged as such.