diff --git a/lib/maptool/pmtiles_builder.rb b/lib/maptool/pmtiles_builder.rb index cccf2e9..de586e8 100644 --- a/lib/maptool/pmtiles_builder.rb +++ b/lib/maptool/pmtiles_builder.rb @@ -4,6 +4,7 @@ require "uri" require "json" require "tmpdir" require "fileutils" +require "etc" module Maptool # 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 # that's data_dir's own "sources" subdirectory) — fetched once, # 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.write(offline_meta_path(data_dir), JSON.generate(sources: sources.map { |s| s.slice("code", "slug", "last_modified") })) ensure