Skip to content

perf: release the --store files from several threads at exit - #973

Open
dktue wants to merge 1 commit into
systemed:masterfrom
dktue:perf/store-teardown
Open

dktue wants to merge 1 commit into
systemed:masterfrom
dktue:perf/store-teardown

Conversation

@dktue

@dktue dktue commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Gain (planet, --store): time from finished output to process exit 30 s → 8 s (−73%; −22 s, about 1.3% of a 1,650 s run). Output unchanged.

With --store, tilemaker keeps its stores in memory-mapped files of 1 GB each. At exit, the static mmap_dir_t destructor unmaps and deletes them one after another. For the planet that is ~140 GB in ~300 files, and it takes about 30 s on one thread after the output is already complete.

This PR releases the files from up to 16 threads (capped by the number of cores). Unmapping different files and deleting them doesn't contend much: the kernel frees each file's pages under a shared lock, and each deletion works on its own inode. It stays in the same destructor, after everything that points into the mapped files is gone. If a thread can't be started, the remaining files are released as before.

Planet, PMTiles, 32 threads, --store --fast

before after
"Filled the tileset" → process exit 30 s 8 s (−73%)

A Germany run with --store exits normally and leaves the store directory empty.

🤖 Generated with Claude Code

Unmapping and deleting the ~300 1-GB store files of a planet run took
~30 s on one thread after the output was complete. Release them from up
to 16 threads; fall back to one if threads can't be started.

Planet: "Filled the tileset" -> exit 30 s -> 8 s (-73%),
about 1.3% of total wall.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant