Repository navigation
Conversation
Id_Predicate checks every object it is shown with std::binary_search over the sorted id list. Most objects it sees are not in the list: a tag query such as node[amenity=restaurant] finds the matching ids in the tag index, then reads every node block of each quadtile that holds one of them and tests each node against the ids. Add a small hashed bit filter (about 16 bits per id, at most 16 MiB) that rejects most absent ids with one bit test; the binary search still decides every id the filter lets through, so results do not change. Collect_Items now builds its predicate once instead of once per chunk. On a Nova Scotia extract (12.6M nodes), median CPU time per query with warm caches: nwr[amenity=restaurant] 160 ms -> 124 ms node[natural=peak] 183 ms -> 129 ms rel boundary with (._;>>;) 682 ms -> 571 ms Outputs are byte-identical. No change to the database format or the API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT
collect_tags_framed reads every local tag entry of a cell and keeps those
of the elements being printed, binary-searching each entry's id among
them. Most entries of a cell belong to other elements.
It now builds an Id_Bit_Filter of the cell's ids and skips entries whose
id the filter rejects before the bound checks and the binary search.
On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
median CPU of 3 alternating runs:
(rel['seamark:type']; >; way['seamark:type']; >; node['seamark:type']; ); out meta;
4.66 s -> 3.66 s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35
cldellow
force-pushed
the
faster-id-predicate
branch
from
November 28, 2026 03:38
70f18bd to
30b37bc
Compare
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.
Stacked on #1 (
faster-id-predicate), which addsId_Bit_Filter. The tables compare against #1's branch.Fixes #250.
Change
collect_tags_framed(data/tag_store.h) builds anId_Bit_Filterof the cell's ids and skips tag entries whose id the filter rejects, before the id bounds and the binary search. It also looks the cell's ids up once.One file, 7 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 alternate, median user+sys CPU of 3 runs. The queries: the 1° × 1° maxheight query from #242 in three boxes (dense, sparse, empty) and their 0.99999° versions, and the 20 heaviest query templates on the public servers in June 2026 moved to Boston and New England coordinates (p01–p20). Base is #1's branch (70f18bd).
Queries that print the tags of many elements gain most: p07 −21%, p18 −20%, p11 −16%.
With #138. On
all-changes, #138 replaces the binary search here with a forward cursor (contains_from_cursor); the bit filter goes in front of that cursor the same way (skipping calls is safe: the cursor restarts when an id isn't greater than the previous one). There it takes dense_1 from 2.54 G to 2.21 G instructions.Queries
dense_1:
sparse_1:
empty_1:
The 0.99999° versions shrink each box's north and east edges by 0.00001°. p01 is dense_1.
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
fuzz,historyandpropsstarted by hand (workflow_dispatchwith this branch asref), since those workflows run on pull requests only againstmaster.Limitations and open questions
Generated by Claude Code