From 35faaef43e53e671be136bda39cd61cdc9c1c7b2 Mon Sep 17 00:00:00 2001 From: Kousik Kumar Date: Thu, 13 Jan 2022 02:13:10 -0500 Subject: [PATCH] Pass along local resource fraction to reproxy Reproxy should be respecting the -j value set by the user and not be doing excessive local executions assuming the whole machine is available to it. The local_resource_fraction flag is a way to ensure reproxy consumes CPU only upto the -j value specified by the user. Test: 1. Ran with `USE_RBE=true m -j 10 nothing` and local_resource_fraction was set to 0.14 on a 72-core workstation. 2. Ran with `USE_RBE=true m nothing` and local_resource_fraction was set to 1.0 on a 72-core machine. Bug: b/207296459 Change-Id: I118bc10109f5a55df7a6c1ecd79499320055f2ed --- ui/build/rbe.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/build/rbe.go b/ui/build/rbe.go index d74f26210..8f9a69991 100644 --- a/ui/build/rbe.go +++ b/ui/build/rbe.go @@ -19,6 +19,7 @@ import ( "math/rand" "os" "path/filepath" + "runtime" "syscall" "time" @@ -87,6 +88,13 @@ func getRBEVars(ctx Context, config Config) map[string]string { } vars["RBE_server_address"] = fmt.Sprintf("unix://%v", name) } + + rf := 1.0 + if config.Parallel() < runtime.NumCPU() { + rf = float64(config.Parallel()) / float64(runtime.NumCPU()) + } + vars["RBE_local_resource_fraction"] = fmt.Sprintf("%.2f", rf) + k, v := config.rbeAuth() vars[k] = v return vars