Skip to content

Commit c1036c6

Browse files
authored
Improve build cache asset handling (#207)
* Improve S3 cache * Do not use all the available CPUs by default * Improve builds * Improve tar operations * Cleanup * Improve handling of compression flag * Cleanup
1 parent 59187a0 commit c1036c6

File tree

7 files changed

+1003
-306
lines changed

7 files changed

+1003
-306
lines changed

cmd/build.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,20 @@ func addBuildFlags(cmd *cobra.Command) {
166166
cacheDefault = "remote"
167167
}
168168

169+
// Never use all CPUs, leave one free for other processes
170+
cpus := runtime.NumCPU()
171+
if cpus > 2 {
172+
cpus--
173+
}
174+
169175
cmd.Flags().StringP("cache", "c", cacheDefault, "Configures the caching behaviour: none=no caching, local=local caching only, remote-pull=download from remote but never upload, remote-push=push to remote cache only but don't download, remote=use all configured caches")
170176
cmd.Flags().Bool("dry-run", false, "Don't actually build but stop after showing what would need to be built")
171177
cmd.Flags().String("dump-plan", "", "Writes the build plan as JSON to a file. Use \"-\" to write the build plan to stderr.")
172178
cmd.Flags().Bool("werft", false, "Produce werft CI compatible output")
173179
cmd.Flags().Bool("dont-test", false, "Disable all package-level tests (defaults to false)")
174180
cmd.Flags().Bool("dont-compress", false, "Disable compression of build artifacts (defaults to false)")
175181
cmd.Flags().Bool("jailed-execution", false, "Run all build commands using runc (defaults to false)")
176-
cmd.Flags().UintP("max-concurrent-tasks", "j", uint(runtime.NumCPU()), "Limit the number of max concurrent build tasks - set to 0 to disable the limit")
182+
cmd.Flags().UintP("max-concurrent-tasks", "j", uint(cpus), "Limit the number of max concurrent build tasks - set to 0 to disable the limit")
177183
cmd.Flags().String("coverage-output-path", "", "Output path where test coverage file will be copied after running tests")
178184
cmd.Flags().StringToString("docker-build-options", nil, "Options passed to all 'docker build' commands")
179185
cmd.Flags().String("report", "", "Generate a HTML report after the build has finished. (e.g. --report myreport.html)")

0 commit comments

Comments
 (0)