diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-11-22 11:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-22 11:32:36 +0100 |
commit | 63fa2455fd0dc5c622f51278ad446e75711e70a0 (patch) | |
tree | 1695c2215f8453502d05b9e145e8a95f1ffacbe3 /client | |
parent | 07e8c4bee1bffd940bdc54bc093566f3d78961b7 (diff) | |
parent | 2416c1698a5262abbe66c7201e1f9bb90d4947cd (diff) |
Merge pull request #29421 from vespa-engine/mpolden/qemu-reduce-freq
Reduce timer frequency when QEMU virtualization is used
Diffstat (limited to 'client')
-rw-r--r-- | client/go/internal/util/tuning.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/client/go/internal/util/tuning.go b/client/go/internal/util/tuning.go index b36c0a431da..cca314247ab 100644 --- a/client/go/internal/util/tuning.go +++ b/client/go/internal/util/tuning.go @@ -15,19 +15,29 @@ import ( func OptionallyReduceTimerFrequency() { if os.Getenv(envvars.VESPA_TIMER_HZ) == "" { backticks := BackTicksIgnoreStderr - out, _ := backticks.Run("uname", "-r") - if strings.Contains(out, "linuxkit") { - if os.Getenv(envvars.VESPA_TIMER_HZ) != "100" { - trace.Trace( - "Running docker on macos.", - "Reducing base frequency from 1000hz to 100hz due to high cost of sampling time.", - "This will reduce timeout accuracy.") + uname, _ := backticks.Run("uname", "-r") + if strings.Contains(uname, "linuxkit") { + setTimerHZ("Docker on macOS detected.", "100") + } else { + virt, _ := backticks.Run("systemd-detect-virt", "--vm") + if strings.TrimSpace(virt) == "qemu" { + setTimerHZ("QEMU virtualization detected.", "100") } - os.Setenv(envvars.VESPA_TIMER_HZ, "100") } } } +func setTimerHZ(description, timerHZ string) { + if os.Getenv(envvars.VESPA_TIMER_HZ) == timerHZ { + return + } + trace.Trace( + description, + "Reducing base frequency from 1000hz to "+timerHZ+"hz due to high cost of sampling time.", + "This will reduce timeout accuracy.") + os.Setenv(envvars.VESPA_TIMER_HZ, timerHZ) +} + func TuneResourceLimits() { var numfiles uint64 = 262144 var numprocs uint64 = 409600 |