Repository navigation
Conversation
Query_Statement collects candidates in chunks and filters each chunk
before collecting the next; MAX_CHUNK_ACCOUNTED_SIZE ends a chunk once
eval_map counts that much. eval_map counts a node as 8 bytes, so 64 MiB
let a chunk hold 8 million nodes, about 100 MB in memory. Queries whose
candidates fit under that, such as a tag filter over a city-sized box,
held all of them at once.
The cap is now 16 MiB accounted (2 million nodes or 128k ways). Chunks end
at index boundaries, so filtering a chunk repeats no work of the previous
one.
On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
peak RSS, CPU as the median of 7 alternating runs:
node["amenity"](42.2,-71.3,42.5,-70.9); out meta;
174 MB -> 77 MB, CPU x0.94
[date:"2018-06-01T00:00:00Z"]; (node["amenity"](42.2,-71.3,42.5,-70.9); way["amenity"](42.2,-71.3,42.5,-70.9);); out meta;
543 MB -> 171 MB, CPU x0.98
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJWpJaGbt8ML6jz9N35
This was referenced Nov 26, 2026
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 #87 (
collect-chunk-cap): it changes the cap that PR introduces. The tables below compare against #87's branch, notupstream/master.Fixes #232.
Change
MAX_CHUNK_ACCOUNTED_SIZE(data/collect_items.h) goes from 64 MiB to 16 MiB accounted: a chunk of collected candidates now holds at most about 2 million nodes or 128k ways before Query_Statement filters it and collects the next.One constant and its comment. No change to the database format, the query API or the results.
[maxsize:]accounting is unchanged.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. p01–p20 are the 20 heaviest query templates on the public servers in June 2026, moved to Boston and New England coordinates. Base is #87's branch (4fd09db).
Peak memory falls by 56–69% for the four queries whose candidates exceeded 16 MiB accounted, and by 19–23% for two more. The rest don't collect that much and are unchanged. Identical output on all 26.
CPU on the four big movers, 7 alternating pairs. No query gets slower; two get faster, probably from the smaller working set:
Queries d1, d4, h5, h8, m1, m3
d1 (adiff amenity buildings)
d4 (diff convert)
h5 (buildings center)
h8 (attic amenity meta)
m1 (meta amenity)
m3 (attic meta highways)
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)
On
all-changes, the same change gives the same picture: m1 169 → 72 MB, p04 275 → 120 MB, h8 211 → 83 MB, d1 221 → 159 MB, total CPU over 28 queries +0.1%.Testing
fuzz,historyandpropsrun on this PR.Limitations and open questions
aroundqueries p02, p10, p12, p17, p20 included), but it is the place to look if a query slows down.Generated by Claude Code