Improve Lighthouse Performance by Deferring Proto Block Initialization#5905
Improve Lighthouse Performance by Deferring Proto Block Initialization#5905stutijain2006 wants to merge 3 commits intosugarlabs:masterfrom
Conversation
|
✅ All Jest tests passed! This PR is ready to merge. |
|
✅ All Jest tests passed! This PR is ready to merge. |
7se7en72025
left a comment
There was a problem hiding this comment.
LGTM @walterbender .
Effectively optimizes the response time of the startup by moving the initialization of noncritical blocks to idle time, which decreases the total blocking time by 55% while providing a good fallback for compatibility.
|
One question: How did you determine which blocks were essential for statrtup? |
|
Actually, a 2nd question as well. Why did you remove node from packages? |
I determined which blocks are essential by looking what actually is required during Activity.init() and initial palette rendering process. Any blocks that are needed to build default stack, render the palettes correctly or support beginner mode and project loading were treated as core and kept in the initial load. Blocks that are not referenced during startup and are only used when some specific palettes are opened were kept in additional. Node was removed from the package as it should not be listed as an npm package dependency in the repository. Node.js is the runtime environment and is already provided by the system. Having node as dependency caused npm to install the node package, leading to a 403 error and smoke-test failure in the CI. Since the project does not require the npm node package itself, removing it resolves the installation error without affecting the functionality. |
|
"to build default stack" ... what happens if the project loading at start up time is not the default stack -- a very common case. re node, can you put that change in a separate PR (and please tag me)? |
You're absolutely right, project loading at start is common scenario and not always the default stack. In the current implementation, core proto blocks required for initial rendering and block instantiation are initialized immediately, while non-critical and advanced blocks are deferred using requestIdleCallBack. I verified that project loading ( including saved projects, macros and plugins) continues to work correctly with this separation. The deferred blocks are not required during synchronous initialization path, and during testing, no race conditions or missing block definitions were observed. Still, if there are some edge cases where an advanced block must be available earlier, then I can adjust the classification accordingly. |
This PR improves initial page load performance by deferring non-critical proto block initialization to idle time using requestIdleCallback.
Previously, all proto blocks (core + advanced) were initialized during Activity.init(), causing significant main-thread blocking during startup.
This change separates block initialization into:
This reduces initial main-thread workload and improves Lighthouse performance metrics without affecting functionality.
What was Changed-
Performance Impact-
Before-
After-
Functional Testing-
All major functionality has been manually tested and verified:
All existing functionality remains intact.