Repository navigation
Conversation
Remove two redundant sorts, and add a guard to avoid a redundant sort in
some cases:
- generate_ids_by_coarse (both overloads) sorted each coarse index's ids
a second time, after already sorting them and removing duplicates.
- filter_ids_by_tags sorts the ids before checking each required key.
The first key's ids are always already sorted, so it now sorts only if
std::is_sorted says they aren't.
Geofabrik Nova Scotia extract, warm cache, 25 alternating pairs:
[out:json]; (node["shop"](44.45,-63.80,44.85,-63.40); node["amenity"](44.45,-63.80,44.85,-63.40); node["tourism"](44.45,-63.80,44.85,-63.40); ); out count;
638 ms -> 561 ms (-13%)
Co-Authored-By: Colin Dellow <cldellow@gmail.com>
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.
This PR speeds some queries by removing unnecessary sorts.
First: both overloads of
generate_ids_by_coarsesorted each coarse index's ids a second time, after already sorting them and removing duplicates.I belive this was a merge artifact from several years ago. The final sort in
generate_ids_by_coarsewas added in 9ea00f9 (2016-06-06) on the out_csv_finetuning branch. master had meanwhile also added sort + unique (3935810, c30c154), and the branch merges (2fd080e, 8ccb933) kept both loops, so since 2017-03-03 the lists have been sorted twice.Impact on queries:
Geofabrik Nova Scotia extract:
A similar speed-up is observed in the much denser Boston area on the northeast-us extract:
Second:
filter_ids_by_tagssorts the ids before checking each required key. The first key's ids are always already sorted, so it now sorts only ifstd::is_sortedsays they aren't.Impact on queries: