Repository navigation
Conversation
Changed_Constraint::get_*_ids_within reads the changelog for the given
period and keeps the changed ids among those the other constraints allow.
filter() then read the whole changelog for the period again, to keep the
collected elements that changed. That second read is redundant: an element
outside the known ids fails another constraint anyway, so the ids from the
first read decide the same.
The constraint keeps the ids get_*_ids_within found, per element type, and
filter() uses them instead of reading the changelog again. get_*_ids (the
path without known ids) clears them, so a statement executed again, as in a
loop, can't reuse a previous execution's ids.
On a US northeast full-history extract (Geofabrik), warm cache, 4-core VM,
median of 3 alternating runs:
node["electrified"="no"](around:250,42.437849,-70.979304)["tiger:zip_left_1"~"^17"](changed:"2008-03-26T21:18:32Z")->.s0; foreach.s0->.it{ .it out ids; (.it; .it >;)->.x; .x out count; } .s0 out meta bb asc;
CPU 16.21 s -> 9.18 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.
Stacked on #98 (
changed-known-ids): it reuses the ids that PR'sget_*_ids_withinfinds. The tables compare against #98's branch.Fixes #240.
Change
Changed_Constraint(statements/changed.cc) keeps, per element type, the idsget_*_ids_withinfound, with a flag that they are valid.filter()uses them when valid instead of reading the changelog again. Elements outside the known ids fail another constraint anyway, so the result is the same.get_*_ids(the path without known ids) clears the flag, so a statement executed again, as in a loop, can't reuse ids from an earlier execution. In each execution the constraint either computes its ids anew, or is skipped because the result is already empty, in which casefilter()has nothing to filter.One file, 20 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; median user+sys CPU and peak RSS per query. Base is #98's branch (3331108). 3 alternating runs.
f3h515 gains least: most of its time is a past-date
rel(bn)/rel(br)recursion, not the changelog.Fuzzing, against
all-changes: seed 4 withhistory,users,complete, 1,500 queries: identical output on 1,494, and 6 hit the memory limit on both builds. Total CPU fell 6.9% over the 1,488 completed on both, up to −54% for single queries.Queries
User names and user ids drawn from the extract are replaced with
(user)andN.f3h1015
f3h1148
f3h1238
f3h138
f3h399
f3h515
f4h1023
f4h1074
f4h1119
f4h162
f4h600
Testing
fuzz.pyagainstall-changes, seed 4,history,users,complete: 1,500 queries, no difference.fuzz,historyandpropsrun on this PR.Limitations and open questions
get_*_ids, the full list),filter()still reads the changelog again. Keeping that list would cost the memory changed: collect only the ids other constraints allow #98 avoids.Generated by Claude Code