Repository navigation
Conversation
filter_by_bbox and filter_attic_elements built each index's filtered result in a new vector by push_back and swapped it in. The kept vector carried up to twice its size in slack from doubling, and the input vector, itself grown by push_back, briefly existed alongside it. Compact each index's vector in place instead, keeping the order, then shrink it to its size. Kept elements are moved only when their slot changes, so ways and relations no longer copy their member vectors when nothing is removed. Output is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01736kJTiuJPoCWZs7RtFYjm
This was referenced Nov 22, 2026
cldellow
added a commit
that referenced
this pull request
Nov 23, 2026
One mutant for each of nine all-changes commits from the memory work: the past-date bbox chunking and its size check (#104), element counting in history collection (#87), the reserved and the 8-byte output references (#121, #150), in-place filtering (#130) and the Tag_Store changes (#128, #140). Each old text occurs once in all-changes at 686a701. The mutate workflow (run 45106469415, seeds 1-40) caught five: 1b30bbb, 0ec8fa9, 7b11467, f7274dc and 686a701. The other four are expected not to be caught, as their notes say: 7d39a64 and 1ef6664 change only memory, and 180c620 and 3f7cfa8 matter only for a query over [maxsize:]. Part of #145. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01736kJTiuJPoCWZs7RtFYjm
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 #129.
Merge after #104. The code doesn't depend on #104, but the gain does. With #104's chunked past-date bbox collection, this lowers peak RSS on every query measured. On
masteralone, it lowers some and raises others by up to 15% (tables below).Change
filter_by_bbox(data/bbox_filter.cc) and both loops offilter_attic_elements(data/collect_members.h) built each index's filtered vector in a new local vector bypush_back, then swapped it in. They now compact the vector in place, keeping the order, thenerasethe tail andshrink_to_fit. A kept element is moved (or copied, for node coordinates) only when its slot changes, andfilter_attic_elementsreads the timestamps before the move.Two files, 34 lines. This doesn't change the query API, the on-disk format or
[maxsize:]accounting. Output is unchanged.Bound: no new allocation except
shrink_to_fit's exact-size copy of each kept vector, which replaces the old push_back-grown copy (up to twice its size).Impact
Warm cache, 4-core cloud VM with 15 GB RAM. Outputs are byte-identical everywhere. Databases: the Geofabrik Nova Scotia extract of 2026-11-08 imported with
--meta(plain), and a Nova Scotia full-history extract (2006 to 2026-11-15) imported with--keep-atticby abetter-importsbuild (history). Both use lz4 compression.Queries
[out:csv(::id;false)]; node(42,-67.6,47.5,-58); out ids;[out:xml]; node(42,-67.6,47.5,-58); out;[out:json]; way[highway]; out geom;[out:xml]; rel(42,-67.6,47.5,-58); out body;[out:json]; nwr[name]; out center;[date:"2018-01-01T00:00:00Z"][out:csv(::count)]; node(42,-67.6,47.5,-58); out count;[date:"2018-01-01T00:00:00Z"][out:json]; way[highway]; out geom;[date:"2018-01-01T00:00:00Z"][out:json]; nwr[name]; out center;[date:"2018-01-01T00:00:00Z"][out:xml]; rel(42,-67.6,47.5,-58); out body;[date:"2012-01-01T00:00:00Z"][out:csv(::id;false)]; node(42,-67.6,47.5,-58); out ids;[date:"2021-03-01T00:00:00Z"][out:csv(::id;false)]; node(42,-67.6,47.5,-58); out ids;[date:"2018-01-01T00:00:00Z"][out:json]; way[highway](44.4,-64.0,45.0,-63.0); out geom;[date:"2018-01-01T00:00:00Z"][out:xml]; node(42,-67.6,47.5,-58); out;On
all-changes(at 7b7d798, which includes #104), without and with this commitOne run of each under GNU time.
Against
masterCPU is the median of 5 (plain) or 3 (history) alternating runs (
bench/compare.py --no-cache); peak RSS is from one extra run under GNU time (--rss). R21 is one run of each under GNU time, on top of #128, because onmasterits CPU is dominated by the quadratic pass that #126 and #128 remove.masterBenchmark queries q01–q12 (7 runs): total CPU ×1.00, RSS within 1.6 MB on each. History benchmark h1–h6 (5 runs): total ×1.02, RSS within 8.3 MB on each, none higher by more than 0.3 MB. The queries are defined in #2 and #12.
Why R18 and R21 go up on
master: heaptrack on R18 shows the heap peak falls, from 1.11 GB to 1.01 GB, but RSS rises from 1.23 GB to 1.42 GB (heaptrack overhead included). That is fragmentation, not live data. Onmaster, a past-date bbox query collects all candidates of the box at once, current and attic versions, then filters them index by index. Eachshrink_to_fitallocates the exact-size copy while the large vector is alive, and the freed large blocks leave holes that the later, smaller allocations don't fill. With #104, the candidates come in chunks that are freed and reused, and this doesn't happen.Two variants were tried on
master, one run each: withoutshrink_to_fit, and shrinking only when at least half the capacity is slack. Both remove the R18 regression but also all of the gains (R17 1,375 / 1,343 MB, R7 1,289 / 1,269 MB, P2 839 / 839 MB, against 1,348, 1,272 and 845 MB onmaster).Testing
masterand onall-changes.upstream/master(8edf11b), seed 1, no differences:fuzzrun 45112555705: plain 1,990 same and 10 skipped,areas,complete1,999 and 1,evaluators1,998 and 2. Skipped means a timeout or resource limit, which isn't compared.historyrun 45109177980,history,users,complete: 998 same, 2 skipped.propsrun 45109197296, 60 seeds: no new failures. The 9 checks that fail also fail onupstream/master.all-changes(0ec8fa9 in Mutants for the memory commits on all-changes #153) is caught by 18 property checks.Limitations
masteralone, past-date bbox queries over very large boxes can peak higher (R18, R21). Hence "merge after bbox query: collect and filter nodes in chunks at a past date #104".push_back; the slack is only removed after filtering.🤖 Generated with Claude Code
https://claude.ai/code/session_01736kJTiuJPoCWZs7RtFYjm