Repository navigation
Conversation
|
CI on this PR, against
The only benchmark query with Paired runs on the
p12 is dominated by case-insensitive regexes (59% of its CPU in glibc's regex code) and has only a few hundred candidate ways; in a profile of this build, Generated by Claude Code |
|
Re-measured p12 on a quiet machine,
Both are within noise; the 1.056 above didn't hold up. Identical output. Generated by Claude Code |
…adius To test ways against around, Around_Constraint loads the nodes of every candidate way and measures their distance. A way's index covers all its nodes, so when the whole area of the index lies within the radius of a point, every node of the way does, and the way matches. With a large radius that is most of the ways, yet the filter loaded all their nodes. For around with points (lat/lon, or input nodes, up to 64), move those ways aside before building the geometry store, and keep them. Over a lat/lon box narrower than 180 degrees the distance to a point is greatest at a corner, so the four corners are tested, with a margin of 1 m. The area must also lie in the bbox that add_coord registers the point for, since is_inside only looks there. The one difference: a way that references a node missing from the database has no geometry, and was dropped before. With its index within the radius it is now kept. Consistent databases have no such ways. On a US northeast extract this query takes about half the CPU and a third less memory: [out:json]; way[highway](around:25000,42.3601,-71.0589); out count;
324a939 to
4c1c070
Compare
Fixes #183.
Change
Around_Constraint::filter(const Statement&, Resource_Manager&, Set&)(statements/around.cc) now moves aside the current ways for which the newAround_Statement::contains_index_areareturns true before it builds theWay_Geometry_Store, and puts them back after filtering the rest.contains_index_area(idx)takes the index's south-west and north-east node tiles fromcalc_bbox_boundsand returns true if, for one of the points, all four corners of that area are withinradius - 1m (great_circle_dist). It returns false when:around, or ways or relations in the input), more than 64 points, or a radius of 1 m or less;add_coordregisters the point for (same formula, and only when that bbox doesn't wrap or reach 89.9 degrees).Why this keeps the results:
cos dfalls monotonically with the longitude difference; along a meridian,cos d = R cos(lat - lat0)has a single maximum, so the distance has a single minimum. The distance has no maximum inside the box short of the antipode.add_coordregistered the point for, soAround_Statement::is_inside(lat, lon)finds it, and the existing node pre-check inis_inside(way_geometry)returns true.Rebased onto
upstream/master555f744, which adds a bounding-box pre-check toaround(Prepared_BBox,matches_bboxes) and stores each point asstd::pair<Prepared_BBox, Prepared_Point>. The conflict resolution keeps both pre-checks;contains_index_areareads the point from the pair's second member.Attic ways and relations are unchanged. Two files, 63 lines added. No change to the database format or the query API.
Impact
CPU time (user + system) and peak RSS, warm cache, 4-core Intel Xeon VM (2.1 GHz), against
upstream/master555f744, in alternating pairs (15 per query) with the per-pair ratio of this build to the baseline. Two databases: the Geofabrik Nova Scotia extract of 2026-11-08, and the Geofabrik France extract (both imported with--metaand lz4-compressed maps). France replaces the US northeast extract used before the rebase, which is no longer available here; Paris is the densest area in it.upstream/masterMedians shown. All outputs are identical to the baseline.
[out:json]; way[highway](around:25000,44.6488,-63.5752); out count;[out:json]; way[building](around:8000,44.6488,-63.5752); out count;[out:json]; way[highway](around:25000,48.8566,2.3522); out count;[out:json]; way[building](around:8000,48.8566,2.3522); out count;p02, p06, p10 and p17 are production-shaped queries (7–27 statements,
around:500to25000) centred on Paris:The gain grows with the radius: with small radii, few way index areas fit inside the circle. Peak memory falls where it does because the moved-aside ways never enter the
Way_Geometry_Store.Testing
way[highway],way[building],way["natural"="water"]andway[railway]witharoundof 50 m, 600 m, 2 km, 8 km, 25 km and 80 km around Boston, New York, the White Mountains, Providence and Portland (Maine),out ids: all identical toupstream/master.fuzz,historyandpropsrerun on the rebased branch.Limitations
around,aroundfrom ways or relations, and more than 64 points are unchanged; so are relations.https://claude.ai/code/session_01736kJUqyDw9zM3Bkh2W2QT
Generated by Claude Code