You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/kanvas/advanced/performance/index.md
+384Lines changed: 384 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,3 +98,387 @@ To optimize performance, consider the following:
98
98
2. Prioritize using smaller file sizes whenever possible. Use the `webp` image format over `png`, `jpg`, or `gif` as it generally provides significantly better compression, resulting in faster design save times without sacrificing much image quality.
99
99
3. Remove any unnecessary images from your design.
100
100
4. Use image compression tools to reduce the size of your images before adding them to your design.
101
+
102
+
## Compound Node Rendering Performance
103
+
104
+
When working with compound nodes (parent nodes containing multiple child nodes), you may encounter performance challenges as the number of children increases. Understanding these issues and the optimizations available can help you create more responsive designs.
105
+
106
+
### Root Cause Analysis
107
+
108
+
The rendering performance of compound nodes with many children can be significantly impacted by several factors:
109
+
110
+
-**Badge Rendering Plugin Overhead**: The `@layer5/cytoscape-node-html-label` plugin, while powerful for rendering badges and labels, can become a performance bottleneck for compound nodes with many children.
111
+
-**Overly Broad Selectors**: The badge selector `node[?label]` matches virtually every node in the graph, causing unnecessary re-renders even for nodes that haven't changed.
112
+
-**Missing Viewport Culling**: Badges are rendered for all nodes in the design, even those currently off-screen and not visible to the user, wasting computational resources.
113
+
-**Re-render Multiplication**: With 100 child nodes in a compound parent, approximately 303 badge re-renders occur per update cycle.
114
+
-**Drag Operation Overhead**: During interactive operations like dragging, the system can generate 18,000-36,000 function calls per second, leading to UI lag and poor user experience.
Viewport culling is automatically enabled in Kanvas. No configuration is required to benefit from this optimization.
140
+
{{< /alert >}}
141
+
142
+
#### 2. Increased Memoization TTL (70% reduction)
143
+
144
+
Badge rendering is intelligently cached to avoid redundant computations:
145
+
146
+
-**Error Badges**: Cache duration increased from 300ms to 1000ms
147
+
-**Compound Badges**: Cache duration increased from 200ms to 1000ms
148
+
149
+
This means that if a node's state hasn't changed, its badge rendering is reused from cache rather than recomputed.
150
+
151
+
#### 3. Combined Impact (90-95% reduction)
152
+
153
+
When viewport culling and increased memoization work together, the overall reduction in badge re-renders reaches 90-95%, resulting in a dramatically more responsive user interface even with complex compound nodes.
These optimizations were implemented in PR #3917 and address issues documented in #3916 from the layer5labs/meshery-extensions repository.
157
+
{{< /alert >}}
158
+
159
+
## Cytoscape Plugin Performance Considerations
160
+
161
+
Kanvas leverages multiple Cytoscape.js plugins to provide rich interactive features. Understanding the performance characteristics of these plugins can help you anticipate and mitigate potential performance issues.
162
+
163
+
### Plugin-Specific Performance Characteristics
164
+
165
+
#### Compound Drag-and-Drop Plugin
166
+
167
+
The compound drag-and-drop functionality may experience performance degradation with large graphs. This is a known limitation documented in the plugin's own README. If you're working with designs containing hundreds of nodes, consider:
168
+
169
+
- Breaking your design into multiple smaller designs
170
+
- Using the Layers panel to hide unnecessary components during editing
171
+
- Limiting the number of compound nodes with large child counts
172
+
173
+
#### Event Cascade Issues
174
+
175
+
Multiple plugins listening to the same Cytoscape events can create a multiplication effect that compounds performance overhead:
176
+
177
+
-**Grid Guide Plugin**: Listens for drag events to display alignment guides
178
+
-**Automove Plugin**: Monitors node movements to maintain relationships
179
+
-**Popper Plugin**: Tracks node positions for tooltip positioning
180
+
181
+
When all these plugins respond to a single drag event, the computational cost multiplies, potentially causing lag during interactive operations.
182
+
183
+
{{< alert type="info" title="Performance Tip" >}}
184
+
The impact of event cascades is most noticeable during continuous operations like dragging. The render throttling optimizations described later in this document help mitigate this issue.
185
+
{{< /alert >}}
186
+
187
+
#### HTML Plugin Overhead
188
+
189
+
Earlier versions of Kanvas used DOM-based HTML rendering for interactive elements. Migration to a 2D canvas renderer has provided significant performance improvements for:
190
+
191
+
-**Resize Handles**: Canvas-based handles render faster and respond more smoothly
192
+
-**Overlays**: Canvas overlays avoid DOM manipulation overhead
193
+
-**Interactive Controls**: Canvas-based controls reduce browser reflow and repaint operations
194
+
195
+
#### Bubblesets Optimization
196
+
197
+
For designs with complex relationship visualizations, the Bubblesets algorithm has been optimized to provide better performance through improved algorithms that reduce computational complexity.
These optimizations were implemented across multiple PRs: #3885, #3887, and #3500 from the layer5labs/meshery-extensions repository.
201
+
{{< /alert >}}
202
+
203
+
## State Management and Rendering Optimizations
204
+
205
+
Efficient state management is critical for maintaining good performance as your designs grow in complexity. Kanvas employs several sophisticated techniques to optimize state updates and rendering.
206
+
207
+
### Fine-Grained Reactivity
208
+
209
+
Instead of expensive JSON snapshot computations that process the entire design state, Kanvas uses fine-grained state updates that only affect the specific parts of the design that have changed.
Fine-grained reactivity is built into Kanvas's state management system and requires no configuration.
219
+
{{< /alert >}}
220
+
221
+
### Render Throttling
222
+
223
+
To prevent UI thrashing during continuous operations, Kanvas implements render throttling that locks down re-renders to a maximum of 10 per second during operations like:
224
+
225
+
- Dragging nodes or groups of nodes
226
+
- Resizing components
227
+
- Panning and zooming the viewport
228
+
- Bulk operations affecting multiple components
229
+
230
+
This ensures that the UI remains responsive even during intensive operations, preventing the browser from becoming overwhelmed with render requests.
231
+
232
+
**Target Performance:**
233
+
- Maximum re-renders: 10 per second
234
+
- Frame time budget: ~100ms per render
235
+
- Typical user-perceived lag: Minimal to none
236
+
237
+
### Selector Optimization
238
+
239
+
Cytoscape selectors used for sharedState snapshots have been optimized to reduce computational overhead:
240
+
241
+
- Use specific selectors instead of broad queries when possible
242
+
- Cache selector results when appropriate
243
+
- Minimize the number of selector evaluations per frame
244
+
- Defer non-critical selector operations to idle time
245
+
246
+
### Evaluation Deferral
247
+
248
+
Kanvas intelligently skips unnecessary feasibility evaluations for events that don't require validation:
249
+
250
+
-**Tap Events**: No feasibility check needed for simple selections
251
+
-**Double-Click Events**: Validation deferred until action is confirmed
252
+
-**Hover Events**: No evaluation unless tooltip or preview is needed
253
+
254
+
This reduces computational overhead for common user interactions that don't modify the design.
State management optimizations were implemented in PRs #3448, #3595, #3121, and #3114 from the layer5labs/meshery-extensions repository.
258
+
{{< /alert >}}
259
+
260
+
## Zoom and Viewport Performance
261
+
262
+
The zoom level and viewport position significantly impact rendering performance. Kanvas implements several optimizations to ensure smooth performance across all zoom levels.
263
+
264
+
### Minimum Zoom Viewport
265
+
266
+
Maintaining a consistent minimum zoom level ensures that detailed rendering works properly across all interactive elements:
267
+
268
+
-**Layers**: All layers render consistently at minimum zoom
269
+
-**Badges**: Error, warning, and info badges remain visible and properly sized
270
+
-**Textboxes**: Text remains readable without excessive scaling
271
+
-**Interactions**: Interactive handles and controls maintain proper hit targets
272
+
-**Device Compatibility**: Consistent experience across desktop, tablet, and mobile devices
273
+
274
+
{{< alert type="warning" title="Zoom Limits" >}}
275
+
Kanvas enforces minimum and maximum zoom limits to ensure optimal rendering performance and usability. Attempting to zoom beyond these limits will have no effect.
276
+
{{< /alert >}}
277
+
278
+
### Progressive Detail Rendering
279
+
280
+
Kanvas implements view filtering based on zoom level to show more or less detail depending on the current viewport:
281
+
282
+
-**Zoomed Out (Low Detail)**: Show component shapes and primary labels only
283
+
-**Medium Zoom**: Add relationship lines and secondary labels
284
+
-**Zoomed In (High Detail)**: Show all badges, annotations, and detailed metadata
285
+
286
+
This approach ensures that rendering resources are focused on visible, meaningful details at each zoom level.
287
+
288
+
**Performance Benefits:**
289
+
- Reduced rendering overhead at low zoom levels
290
+
- Faster panning and zooming operations
291
+
- Smoother performance with large designs
292
+
- Better user experience with progressive disclosure of information
293
+
294
+
### Zoom Rendering Consistency
295
+
296
+
Fixes have been implemented to ensure consistent rendering behavior at all zoom levels:
Zoom and viewport optimizations were implemented in PRs #3528, #3711, and #2292 from the layer5labs/meshery-extensions repository.
305
+
{{< /alert >}}
306
+
307
+
## Performance Testing Guidelines
308
+
309
+
Regular performance testing helps ensure that your designs remain responsive as they grow in complexity. Use these guidelines to validate performance characteristics.
310
+
311
+
### Test Scenarios
312
+
313
+
Validate performance across a range of design complexities:
Performance can vary significantly across browsers. Test in your primary target browsers (Chrome, Firefox, Safari) to ensure consistent experience.
365
+
{{< /alert >}}
366
+
367
+
## Long-term Architecture Recommendations
368
+
369
+
While current optimizations provide significant performance improvements, several architectural enhancements could provide even greater benefits in future versions of Kanvas.
370
+
371
+
### Canvas-Based Badge Rendering
372
+
373
+
Migrating from DOM-based badge rendering to canvas-based rendering could provide 10-100x performance improvement:
374
+
375
+
**Current Approach (DOM-based):**
376
+
- Each badge is an HTML element
377
+
- Browser must manage layout, styles, and reflows
378
+
- Limited by DOM manipulation performance
379
+
380
+
**Proposed Approach (Canvas-based):**
381
+
- Badges rendered directly to canvas
382
+
- No DOM manipulation overhead
383
+
- Batch rendering operations
384
+
- Better control over rendering pipeline
385
+
386
+
**Expected Benefits:**
387
+
- 10-100x faster badge rendering
388
+
- Reduced memory footprint
389
+
- Smoother animations and transitions
390
+
- Better scaling for large designs
391
+
392
+
### Virtual Badge Manager
393
+
394
+
A virtual badge manager would only render badges currently visible in the viewport:
395
+
396
+
**Implementation Strategy:**
397
+
- Track viewport bounds
398
+
- Maintain a spatial index of badge positions
399
+
- Render only badges intersecting with viewport
400
+
- Update dynamically as viewport changes
401
+
402
+
**Expected Benefits:**
403
+
- Constant rendering time regardless of total badge count
404
+
- Seamless handling of designs with thousands of nodes
405
+
- Reduced GPU memory usage
406
+
- Improved scrolling and panning performance
407
+
408
+
### Web Worker Rendering
409
+
410
+
Offloading computationally intensive operations to background threads (Web Workers) could prevent UI blocking:
411
+
412
+
**Candidate Operations:**
413
+
- Badge layout calculations
414
+
- Relationship path computations
415
+
- Validation and feasibility checks
416
+
- Complex selector evaluations
417
+
418
+
**Expected Benefits:**
419
+
- UI thread remains responsive during heavy computations
420
+
- Better multi-core CPU utilization
421
+
- Smoother user experience during intensive operations
Progressive rendering ensures users see the most important information first, even if the design hasn't fully loaded.
446
+
{{< /alert >}}
447
+
448
+
## Performance-Related URL Parameters
449
+
450
+
Kanvas supports several URL parameters that can impact rendering performance and behavior. Understanding these parameters helps you optimize the loading and rendering of your designs.
451
+
452
+
### Full Render Mode
453
+
454
+
The `render=full` URL parameter enables comprehensive rendering of all design elements, including advanced relationships:
For designs with hundreds of components or complex TagSet relationships, full render mode may cause noticeable performance impact. Consider using standard render mode and selectively enabling layers as needed.
476
+
{{< /alert >}}
477
+
478
+
### Additional Parameters
479
+
480
+
For complete documentation on all available URL parameters and their effects, see [URL Parameters](/kanvas/advanced/url-parameters/).
URL parameters can be combined to customize your Kanvas experience. Experiment with different combinations to find the optimal balance between features and performance for your specific use case.
0 commit comments