Skip to content

SVG import is exponentially slow with respect to the number of layers #2515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Keavon opened this issue Apr 4, 2025 · 0 comments
Open
Assignees
Labels
Performance Speed and efficiency improvements

Comments

@Keavon
Copy link
Member

Keavon commented Apr 4, 2025

During the import process, we are finding space to push the nodes. As more nodes are added, each additional node has to account for all the existing ones. So this probably is taking roughly O(n^2) because of:

Image

And we can see the call stack depth grow over time (actually, we're seeing the stack depth grow linearly but take increasingly long to do so over time, hence the inverse of the graph of the equation above):

Image

This repeatedly alternates between these two functions:

  • NodeNetworkInterface::vertical_shift_with_push
  • NodeNetworkInterface::shift_node_or_parent

We should probably avoid running any of this logic and just precompute the coordinates of each layer in the resulting layers that get added to the graph. We should also see if this repeated looping between those two functions can be avoided in the general case, even outside of SVG importing.

Reproduction SVG (takes about 10 seconds to open)

@Keavon Keavon added the Performance Speed and efficiency improvements label Apr 4, 2025
@Keavon Keavon added this to Task Board Apr 4, 2025
@github-project-automation github-project-automation bot moved this to Short-Term in Task Board Apr 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Performance Speed and efficiency improvements
Projects
Status: Short-Term
Development

No branches or pull requests

2 participants