Key Metrics
Three primary metrics are tracked:Loading Time
The time from page request to first block render:- Server response time
- Time to first paint (FP)
- Time to first contentful paint (FCP)
- DOM content load complete
- Load complete
- First block render
Typing Time
Browser response time while typing in the editor. This measures the delay between keypress and visual update.Block Selection Time
Response time when selecting or inserting blocks. Since inserting a block is equivalent to selecting it, this metric covers both operations.Data Module Async Mode
The Block Editor uses Redux for state management through the@wordpress/data package. As the number of blocks grows, global state updates can cause performance issues.
The Problem
With synchronous rendering:- Every state change triggers updates to all subscribed components
- Long posts with many blocks cause UI lag
- Typing becomes sluggish as component count increases
The Solution
Async Mode enables selective synchronous rendering:- The selected block updates synchronously for immediate response
- All other blocks update asynchronously during browser idle time
- Editor stays responsive regardless of content length
Performance Testing
Running Benchmarks Locally
Compare performance across branches:- Prepares test environments for each branch
- Runs performance tests in each environment
- Computes medians for all metrics
- Generates a comparison report
Test Environment Structure
Test Process
For each branch:- Start the wp-env environment
- Run performance test suite
- Stop the environment
- Record results
- Repeat for remaining branches
- Calculate and display medians
CodeVitals Tracking
Performance results are tracked on CodeVitals for the Gutenberg project.Handling CI Variability
GitHub CI resources vary between runs. To ensure consistent tracking:- Each trunk commit is compared to a fixed reference commit
- Relative differences remain consistent despite environment changes
- Trends are reliable even with varying absolute numbers
Updating the Reference Commit
Update when WordPress version requirements change:- Be compatible with the new WordPress version
- Already be tracked on CodeVitals for all metrics
- Have a passing performance job
Optimization Strategies
Reduce Component Re-renders
Use selectors efficiently:Memoize Expensive Calculations
Debounce User Input
Lazy Load Heavy Components
Best Practices
Measuring Performance
React DevTools Profiler
Use the Profiler to identify slow components:- Open React DevTools
- Switch to Profiler tab
- Click record
- Perform actions in editor
- Stop recording
- Analyze component render times