-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speed up code generation ("make codegen") (#6465)
Running "make codegen" only takes 5 minutes in CI, but it takes upwards of 20 minutes locally on macOS. This is because the code generation is disk I/O heavy, and the bind mount of the Antrea source code into the Docker container is very slow on non-Linux hosts (using Docker Desktop or Colima). To speed up code generation, we implement the following 2 changes: 1) Before generating any code, we make a copy of the source tree from the bind mount to a local directory on the container's writable layer. After that, all reads and writes happen in the copy, which is much faster than the bind mount. When we are done with code generation, we copy generated files from the copy back to the original repository as needed. 2) We mount gopkgmod and the gocache as volumes into the container, which persist across runs. This speeds up the code generation process at the cost of a few GBs of storage on the local host. Change 1) uses "git clone" to make a copy of the source tree, which is the most efficient and simple solution. However, it requires that developers first commit all their changes before running "make codegen". Otherwise, uncommitted changes will be ignored, which can impact code generation. However, I have found that it is always a good idea to commit changes beforehand anyway: it makes it easier to check the generated code changes with "git diff" and it makes it easier to rollback changes if needed. Running "make codegen" with committing local changes will result in an error from now on. We also simplify code vendoring (used to include Protobuf dependencies) in hack/update-codegen-dockerized.sh. Before this change, running "make codegen" would take 22 minutes on my macOS laptop. After this change, the first run of "make codegen" takes 9-10 minutes, and subsequent runs take 3-4 minutes. Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
fbd8312
commit 0f75c50
Showing
5 changed files
with
73 additions
and
28 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
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