Skip to content

SVG export: improve performance#26149

Merged
Roy-043 merged 2 commits intoFreeCAD:mainfrom
Lgt2x:svg-export-perf
Dec 20, 2025
Merged

SVG export: improve performance#26149
Roy-043 merged 2 commits intoFreeCAD:mainfrom
Lgt2x:svg-export-perf

Conversation

@Lgt2x
Copy link
Contributor

@Lgt2x Lgt2x commented Dec 14, 2025

During SVG export, most of the time is spent matching edges, creating a O(N^2) loop that significantly impacts performance.

Using a set instead of a list, lookup in edge list becomes O(1), improving SVG export speed. get_edge_descriptor is equivalent to the match test done by DraftGeomUtils.findEdge, but O(1). Logic is unchanged.

Issues

Fixes #22327 #13249

Before and After Images

Exporting the file in #13249 takes a matter of seconds instead of "2 hours".

Lookup in edge list becomes O(1), significantly improving SVG export speed
@github-actions github-actions bot added the Mod: Draft Related to the Draft Workbench label Dec 14, 2025
@maxwxyz maxwxyz added Type: Other Tasks, refactoring, quality improvement, actions, dependencies, packaging, translations or other... backport releases/FreeCAD-1-1 Applied to a PR that is on main to trigger the automatic creation of another PR onto 1.1 labels Dec 14, 2025
@maxwxyz maxwxyz added this to the 1.1 milestone Dec 14, 2025
@maxwxyz maxwxyz moved this from Queue to Merge Meeting in Merge Queue Dec 14, 2025
@Roy-043
Copy link
Contributor

Roy-043 commented Dec 20, 2025

Thanks for contributing to FreeCAD.

@Roy-043 Roy-043 merged commit cead907 into FreeCAD:main Dec 20, 2025
15 checks passed
@github-project-automation github-project-automation bot moved this from Merge Meeting to Done in Merge Queue Dec 20, 2025
github-actions bot pushed a commit that referenced this pull request Dec 20, 2025
* SVG export: use a set to match edges instead of a list

Lookup in edge list becomes O(1), significantly improving SVG export speed

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit cead907)
@github-actions
Copy link
Contributor

Successfully created backport PR for releases/FreeCAD-1-1:

maxwxyz pushed a commit that referenced this pull request Dec 21, 2025
* SVG export: use a set to match edges instead of a list

Lookup in edge list becomes O(1), significantly improving SVG export speed

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit cead907)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport releases/FreeCAD-1-1 Applied to a PR that is on main to trigger the automatic creation of another PR onto 1.1 Mod: Draft Related to the Draft Workbench Type: Other Tasks, refactoring, quality improvement, actions, dependencies, packaging, translations or other...

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Draft: importSVG.py is too slow it should be cpp

3 participants