Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make shapefile processing multi-threaded #614

Merged
merged 3 commits into from
Dec 15, 2023
Merged

Make shapefile processing multi-threaded #614

merged 3 commits into from
Dec 15, 2023

Conversation

systemed
Copy link
Owner

Currently shapefile reading is entirely single-threaded. This PR shunts the geometry processing into separate threads.

The Lua attribute_function doesn't do much, only basic tag remapping. The expensive bit is the geometry assembly, which includes our old friends geom::intersection and make_valid. So we can get away with putting a single mutex around the Lua access rather than creating a Lua state for each thread.

Total processing time is reduced by 6m30 for North America. (The North America .pbf crosses the 180° meridian so it ends up pulling in shapefiles for -180° to 180°.)

This also moves some geometry error output to verbose mode.

The shapefile reader code is very old and needs tidying up and moving into a ShpReader class, but this will do for now. Ideally we should refactor the StoreShapefileGeometry calls out of processShapeGeometry and put them in the calling lambda, which would make more sense conceptually and mean we didn't have to pass so many parameters around. But that will require a little bit of refactoring work on multilinestrings.

@systemed systemed merged commit 6940f98 into master Dec 15, 2023
5 checks passed
@systemed systemed deleted the shp_threads branch December 15, 2023 16:25
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