Skip to content

Conversation

@TheMrZZ
Copy link
Collaborator

@TheMrZZ TheMrZZ commented Aug 4, 2025

Why?

Using a high number of recursive If was slowing down the compilation.

Profiling showed the bottleneck was handleConflict, a O(N) operation that happens everytime we add a new Node.

The fix

I switched the resourceNodes Set to a "custom" Map class, ResourceNodesMap. This automatically manages the Map keys by concatenating the packType and the path components.

Performance improvements

Before

  • Generating 1500 nested if took 33.430s
  • Generating 100k sequential if took 17.02s

After

  • Generating 5000 nested if now takes 0.889s (x37 🚀)
  • Generating 100k sequential if now takes 2.254s (x7.5 🚀 )

More generally, the new O(1) complexity means Sandstone will better scale on large projects.

@TheMrZZ TheMrZZ changed the base branch from master to fernst/improvements August 4, 2025 15:54
@TheMrZZ TheMrZZ marked this pull request as ready for review August 4, 2025 15:54
@TheMrZZ TheMrZZ force-pushed the fernst/performance_improvements branch from a7de1c6 to 738fa2e Compare August 4, 2025 16:13
@TheMrZZ TheMrZZ changed the title Fernst/performance improvements Performance improvements Aug 17, 2025
@TheMrZZ TheMrZZ merged commit b072ccf into fernst/improvements Aug 17, 2025
2 checks passed
@TheMrZZ TheMrZZ deleted the fernst/performance_improvements branch August 17, 2025 17:21
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.

3 participants