Repository navigation
perf(ui,analysis): avoid table Dataset Arc clones and cull route_on snapping - #2934
Conversation
Borrow Dataset and selection in the Attribute Table instead of cloning them across toolbar and cell-edit commands, and drop the date conversion dialog's Dataset before running edit.convertField inline. Also pass Some(snap_m) to nearest_segment in network::route_on while preserving empty-network and distance error messages.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Code reviewI read the full diff, the staged PR metadata, and the surrounding code for Bugs: None found. I checked the window math in Security: None found. Performance: The culling and the removal of the Quality:
AGENTS.md: No hard rule break found. Low-confidence note: the PR says it adds "0 extra layer/table row copies", but the rule asks for a multiple of the layer for changes that store or copy layer data. The date dialog still holds one shared Change sizeCompared: the whole PR against main (merge base 1994173 to PR head 7786e80).
|
# Conflicts: # crates/analysis/src/network.rs # crates/ui-egui/src/table.rs
Code reviewNo bugs, security issues or AGENTS.md breaks found in the changed lines. One performance note is posted inline on Bugs: none found. What I checked:
Security: none. Performance (1, inline): Quality (2):
AGENTS.md: none. The Twins checked: every Not verified: I could not compile or run the tests, since there is no shell here. The borrow-check and test claims rest on reading the code. Change sizeCompared with the base branch (merge base 0286882 to PR head c7b0373).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. |
Summary
Avoid two unnecessary hot-path costs in the Attribute Table and network routing:
Drop
Dataset/selectionclones from the Attribute Table and Date Conversion Dialog (crates/ui-egui/src/table.rs,crates/ui-egui/src/table/dates.rs,crates/ui-egui/src/readjob.rs):table::showpreviously cloned the displayed layer's or standalone table'sDatasetandselectionvector up front and held them across the entire frame, includingedit.delete,edit.addFeature,edit.convertField,edit.deleteField, andedit.setValue. That bumpedArc::strong_countonfeatures.rowsacross every mutating command (pinning the pre-edit rows until the end of the frame and causing toolbar edits to render a stale snapshot for one frame) and copied the entireselectionvector on every repaint.table::shownow reads lightweight header metadata via a short borrow before drawing the toolbar, then borrows(&Dataset, &[usize])only while drawing the grid and resolving field names/types, ending the borrow before any command runs. Only opening the Date Conversion Dialog clones theDatasetfor its background scan.table::dates::shownow movesparams(anddatasetwhenreads_off_frameis enabled on desktop) out ofDialogand dropsDialogbefore runningedit.convertFieldinline (wasm32 and desktop sync paths).readjob::run_presentedalso drops any unusedpreviewsnapshot before inline execution.Enable bounding-box culling in
network::route_on(crates/analysis/src/network.rs):route_onpassedNoneas thewithinbound tonearest_segment, scanning and projecting every segment in the network withhaversine_mon every endpoint snap, even thoughGraph::placealready passesSome(snap_m).route_onnow checkssegs.is_empty()up front (preserving"the layer has no lines"), passesSome(snap_m)tonearest_segment, and maps a culledNoneto the existing"a route end is more than ... from the network"error.Measurements (before vs after)
Measured on this machine before and after the changes:
Network routing (
network::route_on), 50,244-edge road grid (159 x 159), 20 stops (19 legs, 38 endpoint snaps),snap_m = 50.0, release build:route_on(19 legs): 124.014 ms -> 37.085 ms (3.34x faster, 70.1% reduction), with bit-for-bit identical route outputs (total_len = 50275.815092,total_rows = 497).nearest_segment, 20 stops, 5-run mean): 50.284 ms -> 5.172 ms (9.7x faster).Attribute Table & Date Conversion Dialog, starting from
strong_count = 1(expected count inside a mutating command with an Undo snapshot is2: live dataset + Undo snapshot):edit.setValue(cell edit):strong_count3 -> 2 (0 extra UIArcrefs)edit.delete(toolbar delete):strong_count3 -> 2 (0 extra UIArcrefs)edit.addFeature(standalone table Add row):strong_count3 -> 2 (0 extra UIArcrefs)edit.convertField(date dialog inline/wasm path):strong_count4 -> 2 (eliminated 2 extraDatasetclones)Datasetand 400 KBselectionvector cloning.Surfaces & memory
rustgis), browser (rustgis-web, verified withwasm32-unknown-unknown-D warnings), CLI (rustgis-cli), Python (rustgis-python), and phone (ui-touch) fornetwork::route_on, and desktop + browser for the egui Attribute Table and Date Conversion Dialog. Undo/redo and error messages remain unchanged.Update after merging main
mainalready passesSome(snap_m)tonearest_segmentinroute_on(perf: eliminate hot-path allocations in query, routing, k-means, and publish #2926, which also replaced the cloned node and adjacency vectors with an overlay), so the routing code change here is now main's; this PR keeps its regression testroute_on_culls_by_snap_window_with_identical_results_and_errors, which checks culled and unculled snapping match bit for bit and the empty-network and too-far errors stay distinct.table::show(keyboard cell cursor, row menu): the header reads the source through a short borrow, the grid borrows(&Dataset, &[usize]), and every command the frame runs (statistics, convert, delete field, select rows, cell commits) is resolved to owned field names first, so none runs while the borrow or a copy holds the rows.Testing
network::tests::route_on_culls_by_snap_window_with_identical_results_and_errorstable::tests::attribute_table_drops_dataset_borrow_before_mutating_commandstable::dates::tests::date_dialog_drops_dataset_before_inline_convertcargo fmt --checkcargo clippy --locked -p rustgis-analysis -p rustgis-ui-egui --all-targets -- -D warningscargo test --locked -p rustgis-analysis -- networkcargo test --locked -p rustgis-ui-egui -- tablecargo test --locked -p rustgis-ui-egui --test command_idscargo xtask test-hygiene && cargo xtask layers && cargo xtask rows && cargo xtask attributionRUSTFLAGS='-D warnings' cargo build --locked --target wasm32-unknown-unknown -p rustgis-webUI evidence
No visible UI change.
Related issue
Part of codebase performance audit.
Note:
is_layerintable.rsnow checksmatches!(key, ViewKey::Layer(_))rather thanlayer_id.is_some(), so iftable_layeris stale while a standalone table is shown, the panel treats it as a standalone table rather than aiming layer actions at a missing layer id.Summary by CodeRabbit