Skip to content

out meta (benchmark q08): where the time goes #20

Closed

Description

@cldellow

Summary

Investigation of benchmark query q08 found no single fixable waste. The findings are recorded here for later.

[out:xml]; nwr[amenity](44.60,-63.66,44.70,-63.52); out meta;

It takes about 350 ms CPU on the Nova Scotia test database (see #2), with all the changes in #12 applied.

Where the time goes

Varying only the output mode separates the phases (CPU time, median of 5 runs; noise about 10%):

Output XML JSON Phase it adds
out count 213 ms 184 ms finding the objects
out ids 183 ms 189 ms
out skel 199 ms 195 ms
out tags 294 ms 302 ms +about 105 ms: reading tags for output
out body 306 ms 297 ms
out meta 352 ms 337 ms +about 45 ms: metadata (std::set inserts, allocation)

Finding the objects (about 60%)

The plan is already right. The box is under 1 square degree, so bbox reads every object in it and checks tags afterwards. Starting from the tag index instead is slower here, because amenity is common (19,927 objects in the province, 5,609 in this box):

Variant Time Result
nwr[amenity](44.60,-63.66,44.70,-63.52); out count; 185 ms 5,609
nwr[amenity]->.a; nwr.a(44.60,-63.66,44.70,-63.52); out count; 508 ms 5,609
nwr[amenity=restaurant](44.60,-63.66,44.70,-63.52); out count; 53 ms 268
nwr[amenity=restaurant]->.a; nwr.a(44.60,-63.66,44.70,-63.52); out count; 135 ms 268

Costs in this phase:

Tags for output (about 30%)

collect_tags_framed reads node_tags_local/way_tags_local again for the result objects, although the same tag blocks were read during the tag filter. That is a repeated read across statements (filter, then print), similar to the repeated node reads in #16, but caching across statements would be a larger change.

Metadata (about 13%)

Inserting into a std::set<OSM_Element_Metadata_Skeleton>, plus allocation. A sorted vector might be cheaper, but this has not been tried.

Not pursued yet

  • Reading tag blocks once for both filtering and output.
  • Replacing the metadata std::set with a sorted vector.
  • Avoiding the id sort in tag filtering.

The largest single item, LZ4 decompression, is a configuration matter (compression settings per file), not code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT


Generated by Claude Code

Activity

  1. cldellow commented on Nov 21, 2026

    @cldellow
    OwnerAuthor

    The set/vector thing became issue #30 and PR #31. Going to close this now, as I suspect the tag re-read might be a more involved patch vs a quick easy to review one. If it crops up again as worthwhile, we can revisit.

  2. added
    query-perf
    on Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    query-perf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions