Repository navigation
Conversation
Random_File::move_cache_window loaded the whole 256 KiB window of an id map
(65,536 ids) for a lookup that reads one 4-byte entry: an LZ4 window was
decompressed in full, an uncompressed one read in full.
Random_File::get(pos, last) takes the largest key the caller will look up
before leaving pos's window, and move_cache_window decompresses
(LZ4_Inflate::decompress_partial, around LZ4_decompress_safe_partial) or
reads only that far. A later lookup further into the window reads the rest.
put and zlib-compressed maps keep whole windows. get_indexes_ passes each
window's last id, which its sorted input gives exactly.
On the Geofabrik France extract (--meta, lz4-compressed maps), warm cache,
4-core VM, median CPU of 15 alternating runs, for 2,059 node ids (every 50th
node, in id order, of the output of the query below):
[out:csv(::count)]; node(id:...); out count; 169 ms -> 155 ms
(rel['seamark:type']; >; way['seamark:type']; >; node['seamark:type']; ); out meta;
9.82 s -> 9.72 s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT
Owner
Author
|
CI against Generated by Claude Code |
This was referenced Nov 29, 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.
Fixes #269.
Change
Random_File::move_cache_window(template_db/random_file.h) loaded a whole 256 KiB id-map window (65,536 ids) for a lookup that reads one 4-byte entry: an LZ4 window was decompressed in full, an uncompressed one read in full.Random_File::get(pos, last):lastis the largest key the caller will look up before leavingpos's window.move_cache_windowthen decompresses (newLZ4_Inflate::decompress_partial, aroundLZ4_decompress_safe_partial) or reads only up to that entry, and records how many bytes of the window are valid. A later lookup further into the window reads the rest; if a partial decompression returns too little, it falls back to the whole window.put(imports) and zlib-compressed maps keep whole windows.get_indexes_(data/collect_items.h) passes each window's last id, which its sorted input gives exactly. It serves id queries, id filters in query statements, diffs andtimeline.4 files, +82/−8. No change to the database format or the query API.
Impact
CPU time (user + system), Geofabrik France extract imported with
--metaand lz4-compressed maps, warm cache, 4-core Intel Xeon VM (2.1 GHz), againstupstream/master555f744, 15 alternating pairs; paired ratio with 95% CI. Output identical.upstream/master[out:csv(::count)]; node(id:…); out count;with 2,059 node ids, every 50th node (in id order) of the seamark query's output[out:csv(::count)]; node['seamark:type']; out count;(rel['seamark:type']; >; way['seamark:type']; >; node['seamark:type']; ); out meta;On the all-changes branch (#12), where commit 83 looks candidates up by their exact indices,
node['seamark:type']gains more: 0.910 (0.871–0.952).Benchmark queries: sums of medians over 3 pairs, 0.98 on the plain set (21 queries) and 0.98 on the area set (16); the
timingworkflow measures them properly.Testing
upstream/master555f744 on the queries above and on the 37 benchmark queries (Nova Scotia,bench/queries,queries-poi,queries-areas,queries-tools, 3 alternating pairs each).fuzz,history,propsandtimingrun on this PR.Limitations
LZ4_decompress_safe_partialneeds LZ4 1.9.0 or later to be reliable (it had a bug before 1.9.0).Generated by Claude Code