-
-
Notifications
You must be signed in to change notification settings - Fork 11
Improve .build caching for faster builds. Part 2. #67
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7c3222b
Fix mistake with env RUN_IN_DOCKER
Sencudra d39e28b
PoC: could be faster
Sencudra 6a45499
Review fixes
Sencudra 59b2b8b
Add --enable-experimental-prebuilts flag
Sencudra 9f57f80
Fix typo in warmup readme
Sencudra e2a2de8
Remove unwanted changes
Sencudra 898c9ad
Add change log
Sencudra 4152f5b
review fixes. Rename WarmUp to TestEnvironment to reduce misleading p…
Sencudra c58793e
Add imports to make build harder
Sencudra dd8582a
Remove --enable-experimental-prebuilts to buid-test-runner
Sencudra 02c9192
Rename
Sencudra 8e409d4
Fixes
Sencudra 9aeeb67
Rename only exact match
Sencudra 874dc29
Review fixes: readme
Sencudra c449eb3
Review fixes: run.sh fixes
Sencudra b4b05ab
Apply suggestions from code review #1
Sencudra 17cdbb1
Fix jq command and remove "force" flag from commands.
Sencudra 3f38621
Review fixes. Fixing error code propagation.
Sencudra af04602
Review fixes
Sencudra 58da544
Apply suggestions from code review
Sencudra 5a851fc
Revert some inaccurate changes.
Sencudra ceaf487
Update minimal version as required for swift-syntax.
Sencudra 1cc4284
Add directives for linux
Sencudra 18fc1fe
Review fixes.
Sencudra 46037c6
Add missing \n
Sencudra daaf242
Some more review fixes
Sencudra 528df42
Review fixes
Sencudra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
| # Swift build cache warm-up for faster builds inside docker | ||
|
|
||
| ## Overview | ||
|
Sencudra marked this conversation as resolved.
|
||
|
|
||
| This package is used in a production environment as a container for building and testing students' solutions. | ||
| It is built and included in a Docker image with a pre-built .build directory, which minimizes changes in the build graph when applying different exercise solutions. | ||
| Exercise resources are copied into the TestEnvironment package as if they had always been part of it. | ||
|
|
||
| ## The problem with slow build times | ||
|
|
||
| Cold swift builds are slow. | ||
| We need fast feedback — to respond quickly when someone runs an exercise and not hit Docker timeouts. | ||
| This package is used to build warm-up: it prebuilds the .build folder during docker image creation and is used as an environment for building and testing exercises. | ||
|
|
||
| ## Why cold builds are slow? | ||
|
|
||
| When Swift compiles from a clean state, it spends a huge amount of time on resolving dependencies. | ||
| Imports like Foundation, Numerics, Dispatch, etc. pull in a ton of underlying clang and swift modules like SwiftShims, SwiftGlibc, _Builtin_stddef, etc. | ||
|
|
||
| Even if you don’t import them directly, Swift still needs to find, parse, and compile some of them into .build and specifically ModuleCache directory. | ||
|
|
||
| ## What does this package do? | ||
|
|
||
| It simply imports all the common libraries that exercises usually rely on: | ||
|
|
||
| ```swift | ||
| import Foundation | ||
| import Numerics | ||
| import Testing | ||
| @testable import ModuleName | ||
| ``` | ||
|
|
||
| Then it is built during Docker image creation. | ||
| When a student runs their solution, the code for a particular exercise is copied into the TestEnvironment package. | ||
| Then, the package itself is rebuilt with minor changes, such as replacing code in Source and Tests files. | ||
| See `bin/run.sh` for more details on which parts of an exercise are copied into docker image. | ||
File renamed without changes.
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Any particular reason why this is moved outside of the build stage?
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.
Yes, this is the main idea of this PR. Instead of building and copying some minor parts of the artifacts, it builds so-called "TestEnvionment" package inside the final image, leaving all artifacts there, so it’s basically a cold build. Then, when the exercise is run, there is only a minor diff to apply and build time is much faster.