diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-03-06 11:13:42 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-03-06 11:13:42 +0200 |
commit | 1647f89e63fe8e3f16af8b194430f405fc37683f (patch) | |
tree | 94ad5e12fefbe74b9ace0585aec62ee6ff5da114 | |
parent | 89957d48737a55f334cf1958ea09dc893e899a9b (diff) |
Add ability to specify RAM for auxiliary machines
Also drop support for RAM overcommit (unused and likely a bad idea).
-rwxr-xr-x | buildos | 41 | ||||
-rw-r--r-- | doc/manual.cli | 44 |
2 files changed, 59 insertions, 26 deletions
@@ -262,14 +262,19 @@ fi cpu_total="$(lscpu | sed -n -re 's/^CPU\(s\): *([0-9]+)$/\1/p')" +# RAM reserved to the host. +# if [ -z "$ram_reserved" ]; then ram_reserved=4 fi ram_reserved=$(($ram_reserved * 1024 * 1024)) -if [ -z "$ram_overcommit" ]; then - ram_overcommit=1 +# RAM reserved for auxiliary machines. +# +if [ -z "$ram_auxiliary" ]; then + ram_auxiliary=0 fi +ram_auxiliary=$(($ram_auxiliary * 1024 * 1024)) if [ -z "$cpu_reserved" ]; then cpu_reserved=0 @@ -279,11 +284,13 @@ if [ -z "$cpu_overcommit" ]; then cpu_overcommit=1 fi -ram_slice=$(($ram_total - $ram_reserved)) +ram_build_slice=$(($ram_total - $ram_reserved - $ram_auxiliary)) +ram_auxil_slice=$ram_auxiliary cpu_slice=$(($cpu_total - $cpu_reserved)) if [ "$instances" -gt 1 ]; then - ram_slice=$(($ram_slice * $ram_overcommit / $instances)) + ram_build_slice=$(($ram_build_slice / $instances)) + ram_auxil_slice=$(($ram_auxil_slice / $instances)) cpu_slice=$(($cpu_slice * $cpu_overcommit / $instances)) if [ "$cpu_slice" -eq 0 ]; then @@ -295,23 +302,24 @@ fi # function print () { - echo "cpu_total: $cpu_total" - echo "cpu_reserved: $cpu_reserved" - echo "cpu_overcommit: $cpu_overcommit" - echo "cpu_slice: $cpu_slice" + echo "cpu_total: $cpu_total" + echo "cpu_reserved: $cpu_reserved" + echo "cpu_overcommit: $cpu_overcommit" + echo "cpu_slice: $cpu_slice" if [ -n "$cpu_affinity" ]; then - echo "cpu_affinity: $cpu_affinity" + echo "cpu_affinity: $cpu_affinity" fi echo - echo "ram_total: $ram_total KB" - echo "ram_reserved: $ram_reserved KB" - echo "ram_overcommit: $ram_overcommit" - echo "ram_slice: $ram_slice KB" + echo "ram_total: $ram_total KiB" + echo "ram_reserved: $ram_reserved KiB" + echo "ram_auxiliary: $ram_auxiliary KiB" + echo "ram_build_slice: $ram_build_slice KiB" + echo "ram_auxil_slice: $ram_auxil_slice KiB" echo - echo "buildid: $buildid" - echo "buildid_url: $buildid_url" + echo "buildid: $buildid" + echo "buildid_url: $buildid_url" echo local n i tn tp tu tt @@ -936,7 +944,8 @@ function bbot_start () # <toolchain-name> <toolchain-index> sed -i -r \ -e "s#%I#$tn/%I#g" \ -e "s/^(Environment=CPU)=.*/\1=$cpu_slice/" \ - -e "s/^(Environment=RAM)=.*/\1=$ram_slice/" \ + -e "s/^(Environment=RAM_BUILD)=.*/\1=$ram_build_slice/" \ + -e "s/^(Environment=RAM_AUXIL)=.*/\1=$ram_auxil_slice/" \ -e "s/^(Environment=BRIDGE)=.*/\1=$tb/" \ -e "s#^(Environment=AUTH_KEY)=.*#\1=/state/etc/host-key.pem#" \ -e "s/^(Environment=INTERACTIVE)=.*/\1=$ta/" \ diff --git a/doc/manual.cli b/doc/manual.cli index a994e9f..2852064 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -181,23 +181,47 @@ sudo kvm \ A Build OS instances divides available CPUs and RAM (minus reserved, see below) into \i{slices} that are then \i{committed} to each instance of each -toolchain. If you don't expect your builds to utilize these resources at the -same time, then it may make sense to overcommit them to improve utilization. -The respective overcommit values can be specified as ratios with the -\c{buildos.cpu_overcommit} and \c{buildos.ram_overcommit} kernel command -line parameters. For example, given the following CPU overcommit: +toolchain. In case of CPU it normally makes sense to overcommit this resource +in order to improve utilization. This can be achieved by specifying the +overcommit values as a ratio with \c{buildos.cpu_overcommit}. For example, +given the following CPU overcommit: \ buildos.cpu_overcommit=3/2 \ -A Build OS machine with 8 CPUs (hardware threads) and three toolchains will +A Build OS machine with 8 CPUs (hardware threads) and three instances will assign 4 CPUs (\c{8 * 3/2 / 3}) to each slice. -It is also possible to reserve a number of CPUs and an amount of RAM to -Build OS with the \c{buildos.cpu_reserved} and \c{buildos.ram_reserved} -(in GB) kernel command line parameters. If unspecified, 4GB of RAM is -reserved by default. +It is also possible to specify CPU affinity with \c{buildos.cpu_affinity}. +For example, specifying: + +\ +buildos.cpu_affinity=2-9 +\ + +Will restrict the instances to only running on CPUs 2-9. + +It is possible to reserve a number of CPUs and an amount of RAM to Build OS +with the \c{buildos.cpu_reserved} and \c{buildos.ram_reserved} (in GiB) kernel +command line parameters. If unspecified, 4GiB of RAM is reserved by default. + +An amount of RAM can be reserved for auxiliary machines with +\c{buildos.ram_auxiliary}. This amount will also be divided into slices and +committed to each instance. + +Finally, if the total available RAM cannot be auto-detected, it can be +specified manually with \c{buildos.ram_total}. Here is a complete example of +specifying all the possible RAM values: + +\ +buildos.ram_total=64 +buildos.ram_reserved=4 +buildos.ram_auxiliary=12 +\ + +Assuming three instances, the configuration will assign 16GiB of build and +4GiB of auxiliary RAM to each instance and keep 4GiB reserved to Build OS. \h#config-storage|Storage| |