Skip to content

Optimize SVG block caching and remove expensive deep cloning#5904

Open
stutijain2006 wants to merge 3 commits intosugarlabs:masterfrom
stutijain2006:PerformanceCore
Open

Optimize SVG block caching and remove expensive deep cloning#5904
stutijain2006 wants to merge 3 commits intosugarlabs:masterfrom
stutijain2006:PerformanceCore

Conversation

@stutijain2006
Copy link
Contributor

This PR improves the internal SVG caching mechanism used in block rendering.

Changes-

  • Replaced JSON.stringify-based cache keys with lightweight manual string keys.
  • Removed expensive JSON.parse(JSON.stringify(...)) deep cloning in cache logic.
  • Replaced deep cloning with shallow cloning for docks arrays.
  • Applied the optimization consistently across:
    - basicBlock
    - basicClamp
    - argClamp
    - booleanCompare

Why-

  • Reduces serialization overhead during block rendering.
  • Lowers garbage collection pressure.
  • Improves scripting time during startup and block interactions.
  • Maintains existing functionality and rendering behavior.

Impact-

  • Reduced scripting time during performance profiling.
  • No regression in block rendering or movement.
  • No layout or functional changes introduced.
Screenshot 2026-02-25 213538

@github-actions
Copy link
Contributor

✅ All Jest tests passed! This PR is ready to merge.

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