From: Tom Hughes Date: Thu, 14 Dec 2023 17:43:25 +0000 (+0000) Subject: Limit the number of threads used for low zoom renders X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/b88e04237dcfbf1d7c4b7aa6023465f8e4a34f44?ds=sidebyside Limit the number of threads used for low zoom renders --- diff --git a/cookbooks/tile/recipes/default.rb b/cookbooks/tile/recipes/default.rb index 40486dac6..4ceba4a18 100644 --- a/cookbooks/tile/recipes/default.rb +++ b/cookbooks/tile/recipes/default.rb @@ -282,6 +282,8 @@ end nodejs_package "carto" +lowzoom_threads = [node.cpu_cores - 1, node[:memory][:total].to_f / 4194304].min.floor + systemd_service "update-lowzoom@" do description "Low zoom tile update service for %i layer" user "tile" @@ -312,7 +314,7 @@ node[:tile][:styles].each do |name, details| owner "root" group "root" mode "755" - variables :style => name + variables :style => name, :threads => lowzoom_threads end service "update-lowzoom@#{name}" do @@ -606,6 +608,7 @@ template "/usr/local/bin/render-lowzoom" do owner "root" group "root" mode "755" + variables :threads => lowzoom_threads end systemd_service "render-lowzoom" do diff --git a/cookbooks/tile/templates/default/render-lowzoom.erb b/cookbooks/tile/templates/default/render-lowzoom.erb index 834eecc30..eb3e2e84e 100644 --- a/cookbooks/tile/templates/default/render-lowzoom.erb +++ b/cookbooks/tile/templates/default/render-lowzoom.erb @@ -16,7 +16,7 @@ function update_<%= style %> --timestamp=${timestamp} \ --tile-dir=/srv/tile.openstreetmap.org/tiles \ --socket=/var/run/renderd/renderd.sock \ - --num-threads=<%= node.cpu_cores - 1 %> \ + --num-threads=<%= @threads %> \ --map="<%= style %>" \ --max-load=<%= node.cpu_cores - 1 %> \ --min-zoom=0 --max-zoom=12 diff --git a/cookbooks/tile/templates/default/update-lowzoom.erb b/cookbooks/tile/templates/default/update-lowzoom.erb index 81e138076..0455493d9 100644 --- a/cookbooks/tile/templates/default/update-lowzoom.erb +++ b/cookbooks/tile/templates/default/update-lowzoom.erb @@ -12,7 +12,7 @@ function update_tiles --timestamp=$(stat -c %Y "/srv/tile.openstreetmap.org/styles/<%= @style %>/project.xml") \ --tile-dir=/srv/tile.openstreetmap.org/tiles \ --socket=/var/run/renderd/renderd.sock \ - --num-threads=<%= node.cpu_cores - 1 %> \ + --num-threads=<%= @threads %> \ --map="<%= @style %>" \ --max-load=<%= node.cpu_cores - 1 %> \ --min-zoom=0 --max-zoom=12