Skip to content
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

perf(editor): 2.3x* faster #276

Merged
merged 31 commits into from
Dec 30, 2024
Merged

perf(editor): 2.3x* faster #276

merged 31 commits into from
Dec 30, 2024

Conversation

surajshetty3416
Copy link
Member

@surajshetty3416 surajshetty3416 commented Dec 24, 2024

Initial load

(on fairly large page with some components)

Before:
Screenshot 2024-12-30 at 9 42 32 AM

After:
Screenshot 2024-12-30 at 9 43 35 AM
Note: Further optimizing for initial load scripting overhead somehow degrades the UX. Might take a look at it again later once I have the better approach to solve it.

Summary:

  • Event listeners reduced by ~91% (from 11,631 to 1,014 max listeners)
  • Total execution time reduced by ~57% (from 5203ms to 2212ms)
  • Scripting time reduced by ~57% (from 3579ms to 1540ms)
  • Node count reduced by ~53% (from 28,677 to 13,372)
  • Memory usage reduced significantly (peak JS heap reduced from 185MB to 105MB)

Following strategies were used to achieve this:

  • Delegate block level event listeners to parent (this significantly reduces number of events and memory consumption)
  • Commonify context menu, move it out of block and add global event listener. (Affects node count and number of listeners)
  • Convert reference component of a block to computed property (avoids repeated function call to findBlock which highly impacts time required for scripting during initial load)
  • Lazy load layers nodes (affects scripting overhead, node count, and number of listeners)
  • Mark few blocks as "raw" using markRaw where reactivity is not needed (affects scripting overhead) (yet to properly test all scenarios)

Other performance benefits:

Due to event delegation
- Builder can scale better as more blocks are added to the page. (i.e. number of listeners will roughly be consistent irrespective of the size of the page)
- Toggling of other displays (breakpoints) are much snappier as there is very less overhead of attaching events per block. Also, now the breakpoint toggle does not re-render if it is already rendered once (thanks to lazy-show strategy)
- Faster undo/redo

UX Fixes:

  • Do not show editor icon in mobile
  • Show a small screen size warning instead of broken editor
  • Reset hoveredBreakpoint and activeBreakpoint on new breakpoint selection
  • Fade transition while loading page

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.94%. Comparing base (5a23825) to head (801b5c0).
Report is 34 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #276   +/-   ##
========================================
  Coverage    41.94%   41.94%           
========================================
  Files           15       15           
  Lines          906      906           
========================================
  Hits           380      380           
  Misses         526      526           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@surajshetty3416 surajshetty3416 changed the title perf: Faster editor* perf(editor): 2x faster Dec 30, 2024
@surajshetty3416 surajshetty3416 changed the title perf(editor): 2x faster perf(editor): 2.3x* faster Dec 30, 2024
@surajshetty3416 surajshetty3416 marked this pull request as ready for review December 30, 2024 04:51
@surajshetty3416 surajshetty3416 merged commit c317e75 into develop Dec 30, 2024
6 checks passed
@surajshetty3416
Copy link
Member Author

🎉 This PR is included in version 1.13.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@surajshetty3416 surajshetty3416 deleted the perf-handle-resources branch January 3, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant