Commit Graph
16 Commits
Author SHA1 Message Date
BFlat 3bc6bf441b Merge pull request #8075 from dotCooCoo/perf/layer-select-all-one-pass
Layers: a Shift-click in the selection column adds or removes a layer's art in one pass
2026-11-18 13:04:07 +07:00
BFlat d5d66cf8de Merge pull request #8370 from dotCooCoo/perf/swatch-link-roots-set
Swatches: linking the selection's paints checks ancestors through a set
2026-11-18 12:55:21 +07:00
BFlat b92aa98f3e Merge pull request #8369 from dotCooCoo/perf/stroke-targets-set
Stroke panel: stroke.set collects its targets through a set
2026-11-18 12:55:13 +07:00
dotCooCoo bc56d2b49b Merge main into perf/layer-select-all-one-pass 2026-11-17 12:26:57 -08:00
BFlat 409b8ce9d1 Merge pull request #8058 from dotCooCoo/perf/selection-batch-toggle
Selection: select.toggle and select.add with many ids go through the selection once
2026-11-18 03:19:52 +07:00
dotCooCoo c226533bc9 Swatches: linking the selection's paints checks ancestors through a set
Add Used Colors and New Color Group link the selected art's paints to
global swatches through Document::map_solid_paints_in, which drops each
id that sits inside another listed id. It searched the whole id list for
each ancestor of each id, so the work grew with the square of the
selection. It now looks each ancestor up in a set of the ids, as
without_inner in crates/engine/src/cmd/edit.rs does. The roots keep the
order of the list, duplicates and ids missing from the document, so the
same paints are linked in the same order.

- mapping_within_ids_matches_a_search_of_the_ids compares the count, the
  paints visited and the resulting document with the search for every
  list of up to three ids from a nested tree (nested ids in both orders,
  duplicates, a missing id and an empty list).
- crates/engine/examples/link_colors_bench.rs times both ways in one
  process. With 20,000 selected rectangles the call takes 16 ms of CPU
  time instead of 128 ms; with 2,000 it takes 1.4 ms instead of 2.5 ms.
2026-11-17 09:49:45 -08:00
dotCooCoo f40f085d21 Stroke panel: stroke.set collects its targets through a set
A Stroke panel edit with no item lists the selected groups and layers
that have a stroke of their own, then adds the leaves of the other
targets, and it checked each leaf against the growing list, so
collecting the targets took time that grows with the square of the
object count. The command now checks each leaf against a set seeded
with the listed groups and layers. The list is the same: its order is
kept, a group or layer named twice is still listed twice, and a leaf is
listed once.

crates/engine/examples/stroke_targets_bench.rs times both merges on the
same leaves in one process. With 20,000 paths in one group, collecting
the targets takes 0.66 ms of thread CPU time against 55 ms with the list
search, and the whole command takes 60 ms.
2026-11-17 09:49:10 -08:00
BFlat 5caa7954b7 Merge pull request #8230 from dotCooCoo/perf/direction-handles-select-set
Select: Object > Direction Handles selects the paths with one set call
2026-11-17 09:47:06 +07:00
dotCooCoo 30d5552795 Select: Object > Direction Handles selects the paths with one set call
Direction Handles cleared the selection and then added each path on its
own, and each add searched the paths already selected, so building the
selection took time that grows with the square of the path count. The
command now selects the paths with one Selection::set call and adds the
anchor sets in one extend. The selection is the same: paths keep their
order, a repeated path keeps its first place and its last anchor set,
and the side fields are cleared as before.

crates/engine/examples/direction_handles_bench.rs times both ways on the
same paths in one process. With 20,000 four-anchor paths, building the
selection takes 1.9 ms of thread CPU time against 69 ms one path at a
time.
2026-11-16 12:39:16 -08:00
dotCooCoo 58f1129123 Cut Path: the cut ends are selected with one set call
Cut Path at Selected Anchor Points cleared the selection and then added
each cut path in turn, and each add searched the paths already added, so
selecting the cut ends took time that grows with the square of the number
of cut paths. The command now selects them with one Selection::set call,
which skips repeats through a hash set and keeps the order in which each
path first appears, and then adds each cut end's anchor. The selection is
the same in every field; a new test compares it with the one-by-one build
on open, closed and multi-subpath cuts, long lists and an empty list.

The gain shows on large documents. With the 8 middle anchors of each of
5,000 open paths of 10 anchors selected, building the selection of 40,000
cut ends takes 9.7 ms instead of 232 ms of CPU time, and with 2,000 paths
3.2 ms instead of 39 ms (medians of 7 runs of the new
cut_path_select_bench example, both ways in one process).
2026-11-16 10:02:01 -08:00
dotCooCoo 9d722b8342 Layers: a Shift-click in the selection column adds or removes a layer's art in one pass
layer.selectAll {id, add: true} checked each of the row's K objects with
a scan of the S selected objects, then removed or added them one id at a
time, each removal rebuilding the selection and each addition scanning
it again, so a Shift-click on a large layer took O(K*S + K^2). It now checks
the row's art against a set of the selected objects and calls
Selection::remove_all or Selection::add_all once. The resulting
selection, its order, the reply and the highlighted rows are the same
as before.

crates/engine/examples/layer_select_bench.rs times the old loop against
the new command in one process. On a layer of 50,000 objects the whole
command took a median of 733 ms before and 6.9 ms after with all of the
layer's art selected, and 369 ms before and 24 ms after with every other
object selected (7 runs, wall clock on Linux while other builds were
running).
2026-11-16 00:06:39 -08:00
dotCooCoo 87b21ebe55 Selection: select.toggle and select.add with many ids go through the selection once
A Shift-drag marquee sends every object it reaches as one select.toggle
{ids}. Each id used to scan and rebuild the selected objects, so K ids
against S selected objects took O(K*(S+K)). Selection::toggle_all and
Selection::add_all now handle the ids in one pass with a map of each id's
current slot, and the commands use them. The result is the same as
toggling or adding each id in order: an id toggled twice is selected
again at the end, and a removal clears that id's anchors, segments, key
and key anchor.

Select > Inverse looks each selectable object up in a set of the
selected ones instead of scanning the selection for each.
Selection::toggle_target, set_slices and set_guides use the same set
lookups.

crates/engine/examples/selection_bench.rs times the old per-id loops
against the new ones in one process. With 50,000 objects, toggling every
object off took 528 to 655 ms before and 2.5 to 4.6 ms after in 7 runs
(wall clock on a machine that was running other builds).
2026-11-15 22:45:42 -08:00
dotCooCoo ed3efcbd7d Render: a long dashed stroke is outlined only near the view after an edit
A dashed stroke of a path with more than 1,024 path elements was outlined
whole in every frame after an edit. It is now outlined in and around the
view like a solid stroke. dash_kept runs the pattern along every segment
and keeps only the dashes and dots on the segments near the view, so they
sit where dashing the whole path puts them and the pixels are the same.
A pattern too fine to draw is still drawn solid, and that solid stroke is
cropped too.

At 1600 x 1200 the frame after one anchor moves takes 14 ms instead of
102 ms on a filled closed path of 50,000 anchors with 6 pt dashes and
4 pt gaps. anchor_bench now includes that document.
2026-11-05 03:55:48 +07:00
dotCooCoo 8d0f251c37 Examples: anchor_bench's doc comment says what the example prints 2026-11-04 16:55:30 +07:00
dotCooCoo 676cc0ee8e Render: a long stroke is outlined only near the view after an edit
The renderer outlined the whole stroke of an edited path on every frame,
so dragging one anchor of a path with many anchors re-outlined every
segment. A stroke line of more than 1,024 elements without dashes or a
width profile is now outlined only for the segments within the stroke's
reach of the view, inflated by the view's own size on each side. The
cached outline keeps that region, and a frame outside it outlines the
stroke again. Closed subpaths that a wide stroke crosses over stay whole,
and a cut closed subpath is walked from a removed segment so no cut lands
where it starts and ends. The pixels are the same.

At 1600 x 1200, the frame after one anchor moves takes 28 to 30 ms
instead of 103 ms on an open path of 200,000 anchors, and 10 ms instead
of 30 ms on a closed path of 50,000 anchors (the new anchor_bench
example: cargo run --release -p vectorcraft-engine --example anchor_bench).
2026-11-04 16:55:30 +07:00
NetterSilverandClaude Opus 5.5 19d4adb39c Make SVG export def ids linear instead of quadratic
Writer::fresh_id probed prefix-1, prefix-2, ... from 1 on every call,
formatting and hashing each candidate, so writing N gradients, clip
paths or masks cost O(N^2). Ids are never released, so every number
below the last one handed out for a prefix is taken: remember where
the search for each prefix stopped and resume there. The ids written
are the same as before.

examples/still-life.vectorcraft (12k gradients, 6.3 MB SVG) exported
in about 8.6 s (median); it now takes about 0.15 s. Output is byte-identical
for every document in examples/.

Add crates/engine/examples/export_bench.rs to time document.export
on the example documents, and a test pinning the generated id
sequence when object names already take some of the numbers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 11:52:22 +01:00