ReactLynx provides built-in profiling support to help you analyze and optimize the performance of your applications. This feature allows you to trace component rendering, diffing, and state updates in production builds.
When profiling is enabled, ReactLynx automatically instruments the following operations:
| Trace Name | Description |
|---|---|
ReactLynx::render::ComponentName | Time spent in your component's render function |
ReactLynx::diff::ComponentName | Time spent in ReactLynx's diffing algorithm for the component |
ReactLynx::diffFinishNoPatch | Instant event marking when a component's diff produced no patch |
ReactLynx::commit | Time spent committing changes to the native layer |
ReactLynx::patch | Time spent applying patches on the main thread |
ReactLynx::setState | Instant event marking when setState was called |
Profiling is automatically enabled when the Lynx engine's profile recording is active. ReactLynx checks lynx.performance.isProfileRecording() at runtime to determine whether to enable profiling instrumentation.
To start profiling, you need to enable profile recording in the Lynx engine. For detailed instructions on how to record and view traces, see Recording Traces.
This feature requires Lynx 3.0 or later, which provides the necessary profiling APIs:
lynx.performance.profileStart()lynx.performance.profileEnd()lynx.performance.profileMark()lynx.performance.profileFlowId()lynx.performance.isProfileRecording()The ReactLynx::render::ComponentName trace measures the time spent executing your component's render function. This helps identify components with expensive render logic.
The ReactLynx::diff::ComponentName trace measures the time ReactLynx spends comparing the previous and new virtual DOM for a component. High diff times may indicate:
The ReactLynx::diffFinishNoPatch is an instant event that fires when a component finishes diffing but produces no patch. This event includes a componentName argument indicating which component's diff produced no changes.
This trace is useful for identifying unnecessary re-renders. If you see many diffFinishNoPatch events, it means components are frequently re-rendering but not actually producing any UI changes. This is an optimization signal that you may need to:
React.memo or useMemo to prevent unnecessary re-rendersThe ReactLynx::setState trace is an instant event that marks when setState is called. It includes additional metadata:
current state keys: Keys present in the current statenext state keys: Keys present in the next statechanged (shallow diff) state keys: Keys whose values changedThis helps you understand what triggered updates and which state properties changed.
ReactLynx uses flow IDs to connect related trace events. When you call setState, a flow ID is generated and attached to all subsequent operations (diff, commit, patch) triggered by that state update. This allows you to trace the complete flow of an update through the system.

In production builds, component names may be minified and become unreadable (e.g., ReactLynx::render::t instead of ReactLynx::render::MyComponent).
To preserve readable component names, set the displayName property on your components:
Build tools may treat setting displayName as a side effect, which can affect Tree-Shaking optimization. In this case, you can use the following pattern to avoid side effects:
Using this helper function:
Profile in realistic conditions: Test with production builds and realistic data to get accurate measurements.
Focus on hot paths: Pay attention to components that render frequently or handle large amounts of data.
Use displayName: Always set displayName for components you want to profile, especially in production builds.
Analyze flow IDs: Use flow IDs to understand the complete lifecycle of state updates, from setState to final patch.
Look for patterns: Identify components with consistently high render or diff times as optimization candidates.