Repository navigation
Conversation
Query_Statement::filter_by_tags checks tags late for candidates collected
by area: generate_ids_by_coarse copied the id of every candidate into a
map of per-cell id lists, and filter_ids_by_tags then narrowed each list
to the matching ids. All candidate ids were held at once, alongside the
candidates themselves, although only one cell's are needed at a time.
filter_by_tags now creates the map's entries (one per cell, still needed
for the range query and filter_by_ids) without ids, and fill_cell_ids
fills a cell's ids from the items, and attic items at a past date, just
before that cell is filtered. Each list then shrinks to its matches, so
the map ends up holding only those.
On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
median of 3 alternating runs:
node["amenity"](42.2,-71.3,42.5,-70.9); out meta;
peak RSS 174 MB -> 137 MB, CPU 1.46 s -> 1.29 s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35
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.
Fixes #234.
Change
Query_Statement::filter_by_tags(the overload with attic items,statements/query.cc) creates one entry per cell inids_by_coarsewithout ids. The range query andfilter_by_idsstill need every cell.fill_cell_idsfills a cell's ids from the items, and from the attic items at a past date, just beforefilter_ids_by_tagsruns for that cell. The list then shrinks to its matches, so the map ends up holding only matching ids.filter_by_idsalready does.One file, 35 lines added, 3 removed. No change to the database format, the query API or the results.
Impact
US northeast full-history extract (Geofabrik), warm cache, 4-core VM. Builds run alternately; peak RSS and median user+sys CPU of 3 runs per query. Run-to-run CPU noise is about ±4% per query. Base is
upstream/mastera9d8f15.On
upstream/masteronly m1 shows the gain: for d1, h8 and p04 the unchunked candidate collection dominates the peak, which the chunk-cap PRs address. With them (onall-changesplus a 16 MiB cap), this adds −8% on m1 and h8 and −2% on p04 and d4.Instruction counts (valgrind callgrind; these repeat exactly between runs):
Queries m1, d1, d4, h8, s_m1
d1 (adiff amenity buildings)
d4 (diff convert)
h8 (attic amenity meta)
m1 (meta amenity)
s_m1_meta_amenity_small (m1 meta amenity small)
The 20 queries
p01 (maxheight bbox1deg)
p02 (amenities around union)
p03 (admin in area)
p04 (brands bbox ci)
p05 (global data center)
p06 (food around regex)
p07 (global seamark recurse)
p08 (global cameras)
p09 (3d buildings bbox)
p10 (tourism around25k)
p11 (brownfield bigbbox)
p12 (clinic name ci around25k)
p13 (map call meta)
p14 (area by name worship)
p15 (tiny bbox many keys geom)
p16 (hgv restrictions bbox)
p17 (anchored regex around)
p18 (fuel bigbbox)
p19 (venues bbox name ci)
p20 (office around25k)
Testing
upstream/masteron all 10 queries above, and on m1, d1, h8, d4, m3 and p04 again after the final cleanup commit.fuzz,historyandpropsrun on this PR.Limitations and open questions
filter_by_tagsoverload (without attic items) still builds all ids up front. It handles the remaining element kinds and could get the same treatment.[k!=v],[!k]), no positive filter narrows a cell's list, so the map ends up holding all candidate ids as before: no gain there, and no loss.Generated by Claude Code