Skip to content

Commit 389ef4e

Browse files
hzyCopilot
andauthored
fix: PE for skills/trace-analysis (#8)
* fix: PE for `skills/trace-analysis` * chore: add changeset * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Zhiyuan Hong <28915578+hzy@users.noreply.github.com> --------- Signed-off-by: Zhiyuan Hong <28915578+hzy@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 272feba commit 389ef4e

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@lynx-js/skill-trace-analysis": patch
3+
---
4+
5+
fix: PE for `skills/trace-analysis`

packages/skills/trace-analysis/SKILL.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Trace analysis is a relatively complex process involving multiple concepts and t
2020
| LynxView | Similar to WebView in native developing. Renders bundle within host application’s context. |
2121
| Pipeline, `debug.pipeline_id` | The lynx pipeline in Lynx development refers to the sequence of steps a Lynx app takes to convert its internal structures into the visual representation that users see and interact with on their screens. |
2222
| Timing Flags, `debug.timing_flags` | The identifier (flag) of a Pipeline |
23-
| LoadTemplate, `LynxLoadTemplate` | |
23+
| LoadTemplate, `LynxLoadTemplate` | Load the Lynx Bundle (historical "Template"), resulting in FCP |
2424

2525
## Input
2626

@@ -144,7 +144,7 @@ graph TD
144144
VMExec --> DR_Start((Start))
145145
DR_Start --> TriggerJS["Trigger: OnJSPrepared<br/>(Immediate)"]
146146
147-
TriggerJS --> CreateVDOM["QuickContext::Call 'renderPage'<br/>(Create VDOM)"]
147+
TriggerJS --> CreateVDOM["QuickContext::Call 'debug.name = renderPage'<br/>(Create VDOM)"]
148148
149149
CreateVDOM --> LayoutFCP[Layout & Paint]
150150
end
@@ -166,21 +166,30 @@ graph TD
166166
end
167167
168168
subgraph JS_Thread [Lynx JS Thread]
169-
JSBoot[LoadJSApp]
169+
subgraph LoadJSApp [Scope: LoadJSApp]
170+
style LoadJSApp fill:#fff3cd,stroke:#856404,stroke-dasharray: 5 5
171+
LoadScript[App::loadScript]
172+
subgraph ExecScript [Scope: executeLoadedScript]
173+
style ExecScript fill:#fff3ee,stroke:#856404,stroke-dasharray: 5 5
174+
CreateVDOM_JSThread["ReactLynx::diff::*<br/>(Create VDOM at JS Thread)"]
175+
end
176+
end
177+
178+
LoadScript --> ExecScript
170179
171180
subgraph Hydration_Scope_JS [Scope: react_lynx_hydrate]
172181
style Hydration_Scope_JS fill:#ebf8ff,stroke:#3182ce,stroke-dasharray: 5 5
173182
EventDispatch[EventTarget::DispatchEvent]
174-
Hydrate["react_lynx_hydrate<br/>(JS Execution)"]
183+
Hydrate["react_lynx_hydrate<br/>(JS Execution)<br/>(VDOM at JS Thread will hydrate the VDOM at Engine Thread)"]
175184
end
176-
177-
JSBoot -.->|Implicit: Thread Busy| EventDispatch
185+
186+
LoadJSApp -.->|Implicit: Thread Busy| EventDispatch
178187
EventDispatch --> Hydrate
179-
Hydrate --"Update UI (callLepusMethod)"--> UpdateUI
188+
Hydrate --"Update UI (TemplateAssembler::CallLepusMethod)"--> UpdateUI
180189
end
181190
182191
%% Cross-Thread Signals
183-
TriggerJS --"Async Trigger"--> JSBoot
192+
TriggerJS --"Async Trigger"--> LoadJSApp
184193
Lifecycle --"Flow: Dispatch Event"--> EventDispatch
185194
186195
%% Styling Classes
@@ -196,11 +205,15 @@ graph TD
196205

197206
From the graph above, it is easy to analyze the critical paths to reach FCP and Hydration, as well as the performance bottlenecks in each stage.
198207

199-
When writing SQL queries, pay attention to adding the `instance_id` filter condition.
208+
**Note:**
209+
210+
- When writing SQL queries, pay attention to adding the `debug.instance_id` filter condition.
211+
- Filter events by joining the `slice` and `args` tables, and use `debug.timing_flags = "Lynx FCP"` or `debug.timing_flags = "react_lynx_hydrate"` to filter events belonging to the FCP or Hydration stage.
212+
- FCP happens mostly on the Engine Thread, while Hydration involves both the JS Thread and Engine Thread. When analyzing Hydration bottlenecks, consider events on both threads and their dependencies.
200213

201214
### 4 Generate Final Report
202215

203-
Refer to the format in [Output](#Output) to generate the final analysis report.
216+
Refer to the format in [Output](#output) to generate the final analysis report.
204217

205218
## Appendix
206219

0 commit comments

Comments
 (0)