diff options
author | Dan Willemsen <dwillemsen@google.com> | 2017-12-11 14:35:23 -0800 |
---|---|---|
committer | Dan Willemsen <dwillemsen@google.com> | 2017-12-11 22:53:16 +0000 |
commit | 22de216799d97c1f75972717b70355a3017635d9 (patch) | |
tree | 8625efb40831e14eca5fa6e964099d043d3b6f45 /cmd | |
parent | 592faab77ddbc1fc524c27ee1272527c30e4c8a8 (diff) | |
download | build_soong-22de216799d97c1f75972717b70355a3017635d9.tar.gz build_soong-22de216799d97c1f75972717b70355a3017635d9.tar.bz2 build_soong-22de216799d97c1f75972717b70355a3017635d9.zip |
Increase per-process file limits for multiproduct_kati
On large branches (250+ configurations), the open file count can go
over the default 1024 soft limit on Ubuntu. Many systems have increased
that default, but for the ones that haven't, at least opt into the
hard limit until this can be refactored to use fewer open files.
Bug: 70370883
Test: prlimit -n256:4096 build/soong/build_test.bash -only-config
Test: ulimit -Sn 256; build/soong/build_test.bash -only-config (darwin)
Change-Id: I7a952ffc89a0149ab65b04db1523d348daa6ab3e
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/multiproduct_kati/main.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cmd/multiproduct_kati/main.go b/cmd/multiproduct_kati/main.go index 2fee1f78..06c56264 100644 --- a/cmd/multiproduct_kati/main.go +++ b/cmd/multiproduct_kati/main.go @@ -24,6 +24,7 @@ import ( "runtime" "strings" "sync" + "syscall" "time" "android/soong/ui/build" @@ -159,6 +160,30 @@ func (s *Status) Finished() int { return s.failed } +// TODO(b/70370883): This tool uses a lot of open files -- over the default +// soft limit of 1024 on some systems. So bump up to the hard limit until I fix +// the algorithm. +func setMaxFiles(log logger.Logger) { + var limits syscall.Rlimit + + err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limits) + if err != nil { + log.Println("Failed to get file limit:", err) + return + } + + log.Verbosef("Current file limits: %d soft, %d hard", limits.Cur, limits.Max) + if limits.Cur == limits.Max { + return + } + + limits.Cur = limits.Max + err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limits) + if err != nil { + log.Println("Failed to increase file limit:", err) + } +} + func inList(str string, list []string) bool { for _, other := range list { if str == other { @@ -228,6 +253,8 @@ func main() { trace.SetOutput(filepath.Join(config.OutDir(), "build.trace")) } + setMaxFiles(log) + vars, err := build.DumpMakeVars(buildCtx, config, nil, []string{"all_named_products"}) if err != nil { log.Fatal(err) |