Skip to content

Conversation

SethFalco
Copy link
Member

@SethFalco SethFalco commented May 11, 2025

In a recent PR, I introduced a significant performance regression to SVGO. This was missed as it only had a noticeable impact on very large SVGs. In the SVG from #2075, it took 70~ seconds to optimize before the commit, then 240~ seconds after the commit.

This fix takes it down to around 74~ seconds on my machine.

Instead of populating the map of nodes to parent nodes eagerly when creating the css-select Adapter, we now defer it to when css-select would actually invoke the Adapter#getParent method. In most instances, the map was never being used, so it was a waste of compute to initialize and populate the map.

To avoid Rollup reporting circular dependencies, I've created a util directory, and migrated some of the helpers to isolated files.

Related

@SethFalco SethFalco merged commit 26d059f into svg:main May 11, 2025
14 checks passed
@SethFalco SethFalco deleted the fix-performance-regression branch May 11, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant