Repository navigation
fix(map): the held-places grid is made without a box kept per row (C2f-6) - #2906
Conversation
…s memory and contract as they are
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
| /// The rows of `rows` whose shape's box may meet `within` (a superset of those that do; one | ||
| /// without a shape only past `u32::MAX` rows, when every row is given), each once, in order. The grid is made again only once the rows | ||
| /// change. |
There was a problem hiding this comment.
The reflowed doc comment has one line about 140 characters long, and the last line holds only "change.". Rewrapping it keeps the lines under the usual width:
| /// The rows of `rows` whose shape's box may meet `within` (a superset of those that do; one | |
| /// without a shape only past `u32::MAX` rows, when every row is given), each once, in order. The grid is made again only once the rows | |
| /// change. | |
| /// The rows of `rows` whose shape's box may meet `within` (a superset of those that do; one | |
| /// without a shape only past `u32::MAX` rows, when every row is given), each once, in order. | |
| /// The grid is made again only once the rows change. |
Category: quality
There was a problem hiding this comment.
This merged before the fix was pushed; the rewrap goes into the next C2f PR.
There was a problem hiding this comment.
Carried into #3018 (C2f-7 part 2) as promised.
| /// would take 32 bytes a row while the grid is made). Capped at 256 by 256 cells, so the | ||
| /// cells' headers (24 bytes each) take about 1.5 MB at most; each row is listed at 4 bytes a | ||
| /// cell it is in, in at most [`MAX_CELLS_PER_ROW`] cells (usually one to four), or once in | ||
| /// the wide list. |
There was a problem hiding this comment.
The memory comment says each row is listed "at 4 bytes a cell it is in", but the cell lists are Vec<u32>, and a growing Vec keeps spare capacity, so the real figure can be higher than 4 bytes per listing. "(usually one to four)" is also not measured anywhere in this PR. Either say "at least 4 bytes" or measure with cargo xtask memory and state the number. This matters because the comment is the place that records the grid's cost against the layer size.
Category: quality
There was a problem hiding this comment.
This merged before the fix was pushed. The next C2f PR changes the comment to "at least 4 bytes per listing, more where a cell's list keeps spare room" and drops the unmeasured "usually one to four".
There was a problem hiding this comment.
Carried into #3018 (C2f-7 part 2) as promised.
| let (mut total, mut shaped) = (Extent::EMPTY, 0usize); | ||
| for i in 0..rows.len() { | ||
| let e = box_of(i); | ||
| if !e.is_empty() { | ||
| total = total.union(&e); | ||
| shaped += 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
This removes the 32-byte-per-row box list, but the grid is still built synchronously from held_places (crates/engine/src/cmd/design.rs:1474), which runs inside edit commands. Every row's geometry and extent are now computed twice on the first search after an edit, and the cell sizes need the total box before the second walk can start, so the second walk can't be avoided with this layout. The PR says so, and the trade-off is reasonable for a 10 million row layer. It would still be worth timing the first search after an edit on a large layer, before and after, so the cost is known rather than estimated. Confidence is medium-low, since the per-row extent is cheap and the real cost depends on vertex counts.
Category: performance
There was a problem hiding this comment.
Not timed. The second walk does the same work as the first, one Geometry::extent per row, which is also what held_places did on every command before #2895. So the first search after an edit costs about two of the old per-command scans, and later searches cost nothing until the rows change. Timing it on a large layer is worth doing once the edited layer's grid is updated in place rather than rebuilt, which is noted for #2032.
Code reviewI read the diff, the two changed files, the grid tests, Bugs: None found. I checked that the two-walk build gives the same grid as before, that the Security: None found. No Performance:
Quality:
AGENTS.md:
Already raised by earlier reviews: 0. There were no prior review threads on this PR. Change sizeCompared with the base branch: the whole PR against main (merge base f5cf513 to PR head 1133c94).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
… a map in its system written as placed (C2f-7 part 2) (opengeos#3018) * feat(edit): vertex handles in the map's coordinates; on a map in the layer's own system edits are written as placed (C2f-7 part 2) Edit Vertices puts each selected feature where the map draws it (Flat::held), not through longitude/latitude: on a map in the layer's own system the handles are its stored coordinates, a dragged vertex is written there as placed (edit.vertex / edit.moveSharedVertex x, y), and a feature with no longitude/latitude place gets handles. Deleting a vertex edits the stored geometry. The globe keeps longitude/latitude; snapped vertices go by longitude/latitude so the place snapped to stays as stored. Carried over: split_own doc, edit.trace params and editing.md wrap (opengeos#2900), row_boxes docs (opengeos#2906). * fix(edit): a snapped vertex is committed at the longitude/latitude it snapped to; a release with no place is said From the pre-push review: the snapped place now goes to the command as snapping gave it, not after a round trip through the map's coordinates (inexact on Web Mercator for lon/lat layers). A release where the map's coordinates have no longitude/latitude says so. A null lon/lat beside x/y is no place. edit.moveSharedVertex x/y documented and tested; projection hashed directly. * test(edit): integration tests read a drag's place through VertexDrag::lonlat VertexDrag::at is in view coordinates now; VertexDrag::lonlat gives the longitude/latitude a release commits (where it snapped, else the pointer's place). * docs(edit): VertexDrag::lonlat says what a release writes; the snap test asserts its place doesn't round-trip * fix(edit): drags cancel on a projection change; snapped moves on features with no lon/lat; half lon/lat pairs refused; release notice tested * test(edit): a lon/lat vertex move on a feature with no lon/lat place is written in its own coordinates
Refs #2032 (C2f-6)
Follow-up to #2895 from its late review notes. The places-an-edit-keeps grid is now made without keeping a box per row, and its comments describe its memory and its contract as they are.
row_boxes.rs):Grid::newwalks the rows twice, once for the box they are all in and once to list each row's box. Before, it kept a box for every row while it worked, 32 bytes a row (about 320 MB for 10 million rows), at the first search after each edit. That list is gone. The cost is a second walk over the vertices.rows_touchingdoc: pastu32::MAXrows every row is given, including rows without a shape. The doc said that never happens. Its only caller checks each row's shape and box, so nothing visible changes.Internal only: no command, user guide or other surface changes. The grid tests pass unchanged.
Summary by CodeRabbit
Performance
Documentation