Tell Planetiler explicitly how many CPUs it has
CI / check (push) Successful in 18s
CI / deploy (push) Successful in 12s

Its own autodetection was leaving most of a 16-core host idle
(observed in production) — likely a container cgroup/JVM detection
quirk. Etc.nprocessors asks the OS directly instead.
This commit is contained in:
randy committed 2026-09-12 01:34:29 +02:00
1 parent f09b5de6c2
commit f5eb9a4a8d
1 file changed
+7 -1
+7 -1
View File
@@ -4,6 +4,7 @@ require "uri"
require "json" require "json"
require "tmpdir" require "tmpdir"
require "fileutils" require "fileutils"
require "etc"
module Maptool module Maptool
# Regenerates data/offline.pmtiles and data/terrain.pmtiles for the # Regenerates data/offline.pmtiles and data/terrain.pmtiles for the
@@ -276,7 +277,12 @@ module Maptool
# this process's working directory (the app root, so in practice # this process's working directory (the app root, so in practice
# that's data_dir's own "sources" subdirectory) — fetched once, # that's data_dir's own "sources" subdirectory) — fetched once,
# reused by every later build. # reused by every later build.
run_planetiler!("--osm-path=#{osm_path}", "--output=#{tmp_path}", "--download") # --threads: Planetiler's own core-count autodetection can come up
# short in a container (cgroup/JVM detection quirks vary by runtime),
# leaving most of a many-core host idle — Etc.nprocessors asks the
# OS directly (sched_getaffinity on Linux), which correctly reflects
# whatever's actually usable by this process even under a container.
run_planetiler!("--osm-path=#{osm_path}", "--output=#{tmp_path}", "--download", "--threads=#{Etc.nprocessors}")
File.rename(tmp_path, File.join(data_dir, "offline.pmtiles")) File.rename(tmp_path, File.join(data_dir, "offline.pmtiles"))
File.write(offline_meta_path(data_dir), JSON.generate(sources: sources.map { |s| s.slice("code", "slug", "last_modified") })) File.write(offline_meta_path(data_dir), JSON.generate(sources: sources.map { |s| s.slice("code", "slug", "last_modified") }))
ensure ensure