extract: scan way nodes once across all extracts in complete_ways pass 1#314
Open
yuiseki wants to merge 1 commit into
Open
extract: scan way nodes once across all extracts in complete_ways pass 1#314yuiseki wants to merge 1 commit into
yuiseki wants to merge 1 commit into
Conversation
This was referenced Apr 29, 2026
Member
|
I understand why this optimization helps for longer ways, going over 2000 way nodes multiple times adds memory accesses which might be outside the memory cache in the CPU. But I wonder whether this is also the case for ways with only a few nodes. Could you try measuring the impact if the old algorithm is used for ways with a small number of nodes? |
joto
requested changes
May 10, 2026
Member
joto
left a comment
There was a problem hiding this comment.
Apart from the variable name and the other comment about short ways this looks good.
| // Default implementation: call eway() for each extract separately. | ||
| // Subclasses may override this to process all extracts in a single | ||
| // pass over way.nodes(). | ||
| void eway_all(std::vector<extract_data>& exts, const osmium::Way& way) { |
Member
There was a problem hiding this comment.
exts -> extracts. No reason to be too stingy with characters in variable names.
| // eway() loop when there are more than 64 extracts. | ||
| // Pass A finds which extracts claim this way. | ||
| // Pass B records all node refs into extra_node_ids for matched extracts. | ||
| void eway_all(std::vector<extract_data>& exts, const osmium::Way& way) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #312.
In Pass 1 of
--strategy=complete_ways,eway()is called independently foreach extract on every way. This means
way.nodes()is scanned up to twice perextract, giving up to 2N scans total for N extracts.
This adds an
eway_all()override instrategy_complete_waysthat scansway.nodes()at most twice regardless of N. Auint64_tbitmask tracks whichextracts have claimed the way in the first pass; the second pass then records
all node refs into
extra_node_idsfor matched extracts only.When there are more than 64 extracts the method falls back to the original
per-extract
eway()loop.Benchmark
japan-260423.osm.pbf (~1 GB), 8-tile extraction:
planet-260413.osm.pbf (~86 GB), 16-tile extraction:
Output verified to be identical to the upstream result for all tiles.