From e13033f5955aea7efe654fa71e4e01f158a5a8bb Mon Sep 17 00:00:00 2001 From: dktue <2878623+dktue@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:41:01 +0100 Subject: [PATCH] perf: sort the tile list with at most 16 threads boost::sort::block_indirect_sort gets very slow with many threads: sorting the planet's tile list took 200-300 s at 96 threads (the threads spinning on its internal lock) and about 7 s at 16. Cap the threads for this sort. Planet, in memory, 96 threads: 29:51 -> 24:43 / 23:50, user CPU -28%. Output unchanged: same comparator, total order. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/tile_sorting.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tile_sorting.cpp b/src/tile_sorting.cpp index 64588163..886005b5 100644 --- a/src/tile_sorting.cpp +++ b/src/tile_sorting.cpp @@ -286,5 +286,7 @@ void sortTileCoordinates( return false; }, - threadNum); + // block_indirect_sort slows down badly with many threads: on the planet (346M tiles) it took + // 200-300 s at 96 threads instead of about 7 s at 16, with the threads spinning on its internal lock. + std::min(threadNum, 16)); } \ No newline at end of file