Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
d311e27
Merge pull request #1 from mufans/refactor-merge
mufans Apr 6, 2026
6edcbfc
Merge pull request #2 from mufans/refactor-merge
mufans Apr 6, 2026
0819136
Merge pull request #3 from mufans/refactor-merge
mufans Apr 8, 2026
7d4499f
feat(attribution): handle anonymous inner classes and improve report …
Apr 9, 2026
e03956a
Merge pull request #6 from mufans/refactor-merge
mufans Apr 9, 2026
a4d99cb
ci: add GitHub Actions workflow for pytest on push to main
Apr 11, 2026
3ae68dc
skip test_collector: Perfetto SQL MODE() WITHIN GROUP not supported
Apr 11, 2026
f31894b
docs: update TODO with optimization suggestions [2026-04-14]
Apr 14, 2026
3921226
docs: add Perfetto UI bridge feasibility study and design
Apr 14, 2026
981c630
docs: add Perfetto UI plugin build instructions to README
Apr 15, 2026
35d518a
feat(perfetto-ui): add interactive frame analysis via self-hosted Per…
Apr 15, 2026
8aad5af
Merge pull request #7 from mufans/refactor-merge
mufans Apr 15, 2026
874e36b
docs: update README with latest report example and formatting
Apr 15, 2026
5932f5c
docs: add Perfetto UI screenshot back to README
Apr 15, 2026
9e86be0
Merge pull request #8 from mufans/refactor-merge
mufans Apr 15, 2026
514727b
docs: add call stack attribution design document
Apr 15, 2026
1273482
feat(attribution): add call stack context for precise source attribution
Apr 15, 2026
f3e7cc3
docs: add Perfetto+AI comparison analysis and improvement plan
Apr 22, 2026
8dc6194
feat(attributor,perfetto): add deterministic fast path and thread sta…
Apr 22, 2026
b550261
Merge pull request #9 from mufans/feat/call-stack-attribution
mufans Apr 22, 2026
38e949a
Merge branch 'master' into feat/p0-improvements
Apr 22, 2026
fc99123
Merge branch 'master' into feat/p0-improvements
Apr 22, 2026
df1a353
feat(frame-analyzer): fix block slice detection, aggregation and inne…
Apr 22, 2026
dc8c00a
fix(perfetto): use overlap-based SQL for thread_state analysis
Apr 22, 2026
f09a9ea
fix(perfetto): accumulate thread state durations and map S+ to Sleeping
Apr 23, 2026
5366cb2
feat(p1): add dependency search, package_list fallback, SELinux bypas…
Apr 23, 2026
902c804
Create thread state blocking analysis design document
mufans Apr 23, 2026
c665c8b
Document project rules and structure in CLAUDE.md
mufans Apr 23, 2026
27d0d68
docs: add logging standard to CLAUDE.md
Apr 23, 2026
3d773eb
feat(collector): rewrite thread_state analysis to use __intrinsic_thr…
Apr 23, 2026
4d7ba1b
refactor(logging): replace bare print() with standard logging in pipe…
Apr 23, 2026
d4224d0
docs: add architecture improvement spec (performance expert + archite…
Apr 24, 2026
09cb419
Add SmartInspector feature specification document
mufans Apr 24, 2026
aa2f627
feat(p0-1): enable IO hooks and integrate IO slices into analysis pip…
Apr 24, 2026
9ff6213
feat(p0-2): add cold start analysis mode with phase splitting
Apr 24, 2026
4f1b295
feat(p0-3): add headless/CI mode with JSON output
Apr 24, 2026
0c39191
feat(p0-4): add JSON report formatter
Apr 24, 2026
34c6690
feat(p0-5): add IO slice attribution support
Apr 24, 2026
f0025a6
feat(p1-1): add Jetpack Compose recomposition tracking
Apr 24, 2026
51f74e5
feat(p1-2): add memory allocation analysis
Apr 24, 2026
edf299c
docs: update README and architecture docs for P0 features and P1 roadmap
Apr 24, 2026
c66f755
feat(p1-3): add historical comparison and trend analysis
Apr 24, 2026
2f31b8c
feat(p1-4): add smart quick analysis mode
Apr 24, 2026
aa06a78
feat(p1-5): improve ExtraHook parameter auto-inference
Apr 24, 2026
046c3c2
docs: add pipeline architecture rule - all features must reuse LangGraph
Apr 24, 2026
f788fa3
docs: add documentation update rule for new commands
Apr 24, 2026
4b2e2ae
docs: add prompt management rule - complex prompts must go to prompts…
Apr 24, 2026
db75a86
docs: add P2-6 source attribution enhancement (inspired by claude-con…
Apr 24, 2026
b7810c6
feat(collector): add cold start auto ADB launch
Apr 24, 2026
3c8996e
feat(scripts): add si.sh CLI launcher script
Apr 24, 2026
335946a
refactor(headless): reuse LangGraph pipeline via graph.invoke()
Apr 24, 2026
d3205a8
docs: update CLI commands and RouteDecision for headless/CI refactoring
Apr 24, 2026
5afc42e
fix(collector): use resolve-activity instead of hardcoded MainActivity
Apr 24, 2026
8c731ff
fix(collector): use LAUNCHER intent instead of resolve-activity for a…
Apr 24, 2026
3dfe06c
docs: update documentation with P0/P1 completion status
Apr 24, 2026
16a83ae
docs: add SQL Summarizer & Analysis Verifier spec
Apr 27, 2026
08c7cca
feat: add SQL Summarizer & Analysis Verifier
Apr 27, 2026
3b61819
Add metric_qa node for natural language metric queries
mufans Apr 28, 2026
05f3d58
feat(graph): add metric_qa node for natural language metric queries
Apr 28, 2026
6ba3060
fix: syntax errors in perfetto.py (callable | None) and compare.py (t…
Apr 28, 2026
aa729a2
fix: logging standard, startup package check, trace reuse bugs
Apr 28, 2026
72607bb
fix: cold start startup pipeline bugs (Fix #10)
Apr 28, 2026
6d4abae
feat(android): add Compose demo page for testing ComposeHook recompos…
May 5, 2026
d764a2a
refactor(logging): replace Python logging module with unified debug_l…
May 5, 2026
0cbaead
fix(startup): improve cold start root cause analysis
May 5, 2026
313b94d
fix(startup): connect startup pipeline to attributor→reporter and fix…
May 5, 2026
7955bd6
fix(startup): preserve startup report in reporter and fix attributor …
May 5, 2026
a416d5a
fix(startup): use LLM report generation for startup route
May 5, 2026
b34f2ff
fix(startup): append startup analysis verbatim to LLM-generated report
May 5, 2026
8faf640
fix(startup): default trace duration to 5s for startup route
May 5, 2026
4481f4b
fix(cli): store --target in initial state for /startup fallback
May 5, 2026
0141ad5
refactor(cli): rename --source-dir to --src (shorter alias)
May 5, 2026
b07631a
docs: update README and CLAUDE.md to use --src
May 5, 2026
c00e12b
fix(attributor): handle DeepSeek thinking mode reasoning_content
May 5, 2026
fa8561e
fix(hook): resolve system layout resource names in inflate tag
May 5, 2026
7a93384
fix(attributor): resolve anonymous inner class blocks via stack trace
May 5, 2026
46903d0
fix(attribution): restore accidentally deleted extract_class function
May 5, 2026
5f667f9
fix(collector): fix SQL errors, thread state resolution, CPU hotspot …
May 5, 2026
aefbdbe
Merge pull request #11 from mufans/feat/metric-qa
mufans May 5, 2026
2449bea
refactor: Phase 1 - unified SI$ tag parsing + test infrastructure
May 6, 2026
77690d9
feat: add lock contention analysis (android.monitor_contention)
May 12, 2026
c2f7301
feat: add binder transaction analysis (android.binder + binder_breakd…
May 12, 2026
afb9424
feat: enhance startup analysis with TTID/TTFD and breakdown (android.…
May 12, 2026
dc76fff
feat: add garbage collection analysis (android.garbage_collection)
May 12, 2026
adea44c
feat: add ANR analysis (android.anrs)
May 12, 2026
efe98b4
feat: add slice CPU time and thread state analysis (slices.cpu_time +…
May 12, 2026
fae6882
feat: add per-frame metrics analysis (android.frames.per_frame_metrics)
May 12, 2026
5c3a513
feat: add input latency breakdown analysis (android.input)
May 12, 2026
4f29df4
feat: add scheduling latency analysis (sched.latency)
May 12, 2026
fc2c829
feat: add OOM score and RSS/Swap tracking (android.memory.process + lmk)
May 12, 2026
451c5ab
feat: add precise CPU utilization tracking (linux.cpu.utilization)
May 12, 2026
cb2e72d
feat: enhance heap analysis with stats, class aggregation and dominat…
May 12, 2026
91045d3
feat: add SurfaceFlinger frame timeline matching (android.surfaceflin…
May 12, 2026
822ba34
docs: update CLAUDE.md for stdlib modules
May 12, 2026
9031b69
docs: update README.md for stdlib modules
May 12, 2026
5fbf427
docs: update ARCHITECTURE.md for stdlib modules
May 12, 2026
fd0fb21
fix: use project.optional-dependencies for dev extras (PEP 621)
May 12, 2026
478f847
fix: rename MemoryMixin to HeapGraphMixin in __init__.py
May 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ reports/
platform/android/.gradle/
platform/android/build/
platform/android/.idea/
perfetto-build/
70 changes: 68 additions & 2 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,20 @@ smartinspector/
│ │ └── deterministic.py # Deterministic pre-computation (reduces LLM tokens)
│ │
│ ├── collector/ # Data collection & processing
│ │ └── perfetto.py # PerfettoCollector: adb collect → SQL query → JSON (CPU调用链, 系统级CPU, WS+SQL合并, context manager)
│ │ ├── perfetto.py # PerfettoCollector: adb collect → SQL query → JSON (CPU调用链, 系统级CPU, WS+SQL合并, context manager)
│ │ ├── frame.py # FrameMixin: per-frame metrics (overrun, cpu_time, ui_time, vsync_delay, jank)
│ │ ├── startup.py # StartupMixin: TTID/TTFD startup metrics + bottleneck breakdown
│ │ ├── memory.py # MemoryMixin: heap graph stats, class aggregation, dominator tree
│ │ ├── lock.py # LockMixin: Java monitor lock contention analysis
│ │ ├── binder.py # BinderMixin: binder transactions + latency breakdown
│ │ ├── gc.py # GcMixin: garbage collection event analysis
│ │ ├── anr.py # AnrMixin: ANR detection + main-thread slice analysis
│ │ ├── slice_enhanced.py # SliceEnhancedMixin: SI$ slice CPU time + thread state distribution
│ │ ├── input.py # InputMixin: input event latency breakdown (dispatch/handling/ACK)
│ │ ├── sched_latency.py # SchedLatencyMixin: scheduling latency per thread
│ │ ├── oom.py # OomMixin: OOM score transitions + RSS/Swap + LMK events
│ │ ├── cpu_utilization.py # CpuUtilizationMixin: frequency-weighted CPU utilization (process/thread)
│ │ └── surfaceflinger.py # SurfaceFlingerMixin: App-SF frame timeline matching
│ │
│ ├── commands/ # Slash command implementations
│ │ ├── __init__.py # Command registry (SLASH_COMMANDS dict + handle_slash_command)
Expand Down Expand Up @@ -431,6 +444,39 @@ PerfSummary
| `collect_threads()` | `thread` | Thread listing |
| `collect_sys_stats()` | `sys_stats` | System-level CPU metrics |

### Stdlib Analysis Modules (Mixin 模式)

所有模块以 Mixin 形式挂载到 `PerfettoCollector`,通过 `INCLUDE PERFETTO MODULE` 引入 Perfetto 标准库。每个 Mixin 依赖宿主提供 `self._open()` (返回 TraceProcessor) 和 `self._target_package`。

#### P0 — 核心模块

| Mixin | 方法 | Perfetto Stdlib (`INCLUDE`) | 采集数据 | 解决的性能问题 |
|-------|------|---------------------------|---------|---------------|
| `FrameMixin` | `collect_frame_metrics()` | `android.frames.per_frame_metrics`<br>`android.frames.timeline` | 每帧行为指标:overrun、cpu_time、ui_time、vsync_delay、jank 分类 (was_jank/was_slow_frame/was_big_jank/was_huge_jank),Top 30 最差帧 | 定位 UI 卡顿根因:区分 CPU 耗时过高、UI 线程慢、VSYNC 延迟等不同类型的帧超时 |
| `StartupMixin` | `collect_startup_metrics()` | `android.startup.startups`<br>`android.startup.time_to_display` | 应用启动事件:TTID (Time To Initial Display)、TTFD (Time To Full Display)、启动类型 (cold/warm/hot) | 量化启动性能:精确定位每次冷启动/暖启动的首次绘制时间和全屏展示时间 |
| `StartupMixin` | `collect_startup_breakdown()` | `android.startup.startups`<br>`android.startup.startup_breakdowns` | 启动瓶颈分解:每段耗时的 reason (binder/io/cpu/lock 等),Top 50 最长段 | 分解启动耗时归因:识别启动期间是 binder 调用、磁盘 IO、CPU 计算还是锁竞争占用了时间 |
| `MemoryMixin` | `collect_heap_graph_stats()` | `android.memory.heap_graph.heap_graph_stats` | 堆图摘要:总/可达对象数量、堆大小、Native 分配、OOM score、RSS/Swap、dmabuf | 内存用量概览:评估应用整体内存健康度,OOM 风险判断 |
| `MemoryMixin` | `collect_heap_class_aggregation()` | `android.memory.heap_graph.heap_graph_class_aggregation` | 按类聚合堆内存 Top 20:对象数量、self size、reachable size、dominated size、native size | 定位内存大户:找出哪些类占用了最多堆空间,区分可达 vs 不可达对象 |
| `MemoryMixin` | `collect_heap_dominator_tree()` | `android.memory.heap_graph.dominator_tree` | 堆支配树 Top 50:对象 ID、immediate dominator、dominated set 大小、retained size、深度 | 追踪内存泄漏:通过支配树找到 retain 最多内存的对象链路,定位泄漏根节点 |

#### P1 — 增强模块

| Mixin | 方法 | Perfetto Stdlib (`INCLUDE`) | 采集数据 | 解决的性能问题 |
|-------|------|---------------------------|---------|---------------|
| `LockMixin` | `collect_lock_contention()` | `android.monitor_contention` | Java 锁竞争事件 Top 20:blocked/blocking 方法、线程名、是否主线程、等待者数量 + 阻塞线程状态分解 | 定位主线程阻塞:识别导致主线程等待的锁竞争,区分 IO 等待 vs CPU 等待 |
| `BinderMixin` | `collect_binder_txns()` | `android.binder` | 同步 Binder 事务 Top 30:client/server 进程线程、AIDL 方法名、是否主线程、client/server 耗时 | 定位跨进程调用瓶颈:找出最耗时的 IPC 调用,识别主线程上的同步 binder 等待 |
| `BinderMixin` | `collect_binder_breakdown()` | `android.binder`<br>`android.binder_breakdown` | Binder 延迟分解 Top 50:client/server 侧的 reason (flush/sched/wait 等)、reason_type | 深入分析 Binder 延迟:区分 binder 调用中的调度延迟、flush 等待、事务执行等各阶段耗时 |
| `GcMixin` | `collect_garbage_collection()` | `android.garbage_collection` | GC 事件 Top 20:wall duration、CPU 时间分解 (running/runnable/io_wait/non_io_wait)、GC 类型、reclaimed 大小、heap 范围 | 评估 GC 影响:识别 GC Stop-The-World 对主线程的实际影响,区分 concurrent vs stop-the-world GC |
| `AnrMixin` | `collect_anrs()` | `android.anrs` | ANR 事件:进程/组件、ANR 类型、subject、timer_delay + ANR 窗口内主线程 Top 10 切片 | ANR 根因分析:识别 ANR 发生时主线程正在执行的耗时操作 |
| `SliceEnhancedMixin` | `collect_slice_cpu_time()` | `slices.cpu_time` | SI$ 切片真实 CPU 时间 Top 20:cpu_time、total_dur、cpu_ratio、线程名 | 区分真实计算 vs 等待:切片耗时长不代表 CPU 慢,cpu_ratio 低说明瓶颈在 IO/锁/调度而非计算 |
| `SliceEnhancedMixin` | `collect_slice_time_in_state()` | `slices.time_in_state`<br>`sched.states` | SI$ 切片线程状态分布 Top 10:Running/Sleeping/Runnable/IO Wait 等状态占比、blocked_function | 诊断切片耗时根因:识别切片时间花在了 CPU 运行、IO 等待、调度等待还是休眠上 |
| `InputMixin` | `collect_input_latency()` | `android.input` | 输入事件延迟 Top 20:dispatch/handling/ACK 三阶段耗时、end-to-end 延迟、事件类型 | 追踪触控响应延迟:区分输入事件在 dispatch、处理、ACK 哪个阶段耗时最长 |
| `SchedLatencyMixin` | `collect_sched_latency()` | `sched.latency` | 线程调度延迟 Top 20:per-thread 的 runnable→running 等待次数、总/平均/最大等待时间 | 识别调度瓶颈:线程 ready 后多久才被 CPU 执行,高调度延迟意味着 CPU 资源竞争激烈 |
| `OomMixin` | `collect_oom_rss_swap()` | `android.memory.process`<br>`android.memory.lmk` | OOM score 变迁 + 内存快照 (anon_rss/file_rss/shmem_rss/swap) + LMK kill 事件 | 内存压力分析:追踪进程 OOM score 变化与内存占用的关系,识别被 LMK 杀死的进程 |
| `CpuUtilizationMixin` | `collect_process_cpu_utilization()` | `linux.cpu.utilization.process` | 进程级 CPU 利用率:频率加权 millicycles/megacycles、runtime、min/max/avg freq、per-second utilization | 精确 CPU 利用率:传统 CPU 使用率不含频率信息,频率加权利用率更准确反映真实 CPU 消耗 |
| `CpuUtilizationMixin` | `collect_thread_cpu_utilization()` | `linux.cpu.utilization.thread` | 线程级 CPU 利用率 Top 15:per-thread 的 millicycles/megacycles、频率信息、per-second utilization | 定位 CPU 热线程:找出哪些线程消耗了最多 CPU 周期,结合频率信息判断是否因低频运行导致性能差 |
| `SurfaceFlingerMixin` | `collect_surfaceflinger_timeline()` | `android.surfaceflinger` | App-SF 帧时间线匹配 Top 200:app/SF 帧时间戳、耗时、期望 deadline、匹配类型 (on_time/late) | 端到端帧延迟分析:从 App 渲染到 SurfaceFlinger 合成的完整链路,识别帧是在 App 端还是 SF 端延迟 |

**Perfetto config**:
- Default categories: sched, freq, idle, power, memreclaim, gfx, view, input, dalvik, am, wm
- `atrace_apps: "*"` — captures app-level atrace markers
Expand Down Expand Up @@ -685,7 +731,27 @@ User: "全面分析列表滑动性能"
│ ├─ collect_frame_timeline()
│ ├─ collect_memory()
│ ├─ collect_view_slices() ← SI$ prefix filtering, rv_instances grouping
│ └─ collect_block_events() ← WS 结构化 JSON + SQL atrace 合并(非覆盖)
│ ├─ collect_block_events() ← WS 结构化 JSON + SQL atrace 合并(非覆盖)
│ └─ Stdlib Mixin modules (via INCLUDE PERFETTO MODULE):
│ ├─ collect_frame_metrics() ← android.frames.*
│ ├─ collect_startup_metrics() ← android.startup.*
│ ├─ collect_startup_breakdown() ← android.startup.startup_breakdowns
│ ├─ collect_heap_graph_stats() ← android.memory.heap_graph.heap_graph_stats
│ ├─ collect_heap_class_aggregation() ← android.memory.heap_graph.heap_graph_class_aggregation
│ ├─ collect_heap_dominator_tree() ← android.memory.heap_graph.dominator_tree
│ ├─ collect_lock_contention() ← android.monitor_contention
│ ├─ collect_binder_txns() ← android.binder
│ ├─ collect_binder_breakdown() ← android.binder + android.binder_breakdown
│ ├─ collect_garbage_collection() ← android.garbage_collection
│ ├─ collect_anrs() ← android.anrs
│ ├─ collect_slice_cpu_time() ← slices.cpu_time
│ ├─ collect_slice_time_in_state() ← slices.time_in_state + sched.states
│ ├─ collect_input_latency() ← android.input
│ ├─ collect_sched_latency() ← sched.latency
│ ├─ collect_oom_rss_swap() ← android.memory.process + android.memory.lmk
│ ├─ collect_process_cpu_utilization() ← linux.cpu.utilization.process
│ ├─ collect_thread_cpu_utilization() ← linux.cpu.utilization.thread
│ └─ collect_surfaceflinger_timeline() ← android.surfaceflinger
└─ State: perf_summary = "{...json...}", _trace_path = "/tmp/xxx.pb"
Expand Down
48 changes: 48 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# SmartInspector - Project Instructions

## Collector 模块 (Perfetto SQL Stdlib 集成)

采集层位于 `src/smartinspector/collector/`,所有模块以 Mixin 形式挂载到 `PerfettoCollector`。每个 Mixin 依赖宿主提供 `self._open()` (返回 TraceProcessor) 和 `self._target_package`。

### 基础模块

| 文件 | 类 | 说明 |
|------|-----|------|
| `perfetto.py` | `PerfettoCollector` | 核心采集器 (adb → SQL → JSON),提供 `_open()` / `_target_package`,所有 Mixin 的宿主 |

### Stdlib 分析模块 (P0 — 核心)

| 文件 | Mixin | 方法 | Perfetto Stdlib |
|------|-------|------|-----------------|
| `frame.py` | `FrameMixin` | `collect_frame_metrics()` — 帧指标 (overrun, cpu_time, ui_time, vsync_delay, jank) | `android.frames.per_frame_metrics`, `android.frames.timeline` |
| `startup.py` | `StartupMixin` | `collect_startup_metrics()` — TTID/TTFD 启动耗时 | `android.startup.startups`, `android.startup.time_to_display` |
| `startup.py` | `StartupMixin` | `collect_startup_breakdown()` — 启动瓶颈分解 | `android.startup.startup_breakdowns` |
| `memory.py` | `MemoryMixin` | `collect_heap_graph_stats()` — 堆图摘要统计 | `android.memory.heap_graph.heap_graph_stats` |
| `memory.py` | `MemoryMixin` | `collect_heap_class_aggregation()` — 按类聚合堆内存 (Top 20) | `android.memory.heap_graph.heap_graph_class_aggregation` |
| `memory.py` | `MemoryMixin` | `collect_heap_dominator_tree()` — 堆支配树 (最大 retained size) | `android.memory.heap_graph.dominator_tree` |

### Stdlib 分析模块 (P1 — 增强)

| 文件 | Mixin | 方法 | Perfetto Stdlib |
|------|-------|------|-----------------|
| `lock.py` | `LockMixin` | `collect_lock_contention()` — Java 锁竞争分析 | `android.monitor_contention` |
| `binder.py` | `BinderMixin` | `collect_binder_txns()` — Binder 事务 Top 30 | `android.binder` |
| `binder.py` | `BinderMixin` | `collect_binder_breakdown()` — Binder 延迟分解 | `android.binder`, `android.binder_breakdown` |
| `gc.py` | `GcMixin` | `collect_garbage_collection()` — GC 事件分析 | `android.garbage_collection` |
| `anr.py` | `AnrMixin` | `collect_anrs()` — ANR 检测与分析 | `android.anrs` |
| `slice_enhanced.py` | `SliceEnhancedMixin` | `collect_slice_cpu_time()` — SI$ slice 真实 CPU 耗时 | `slices.cpu_time` |
| `slice_enhanced.py` | `SliceEnhancedMixin` | `collect_slice_time_in_state()` — SI$ slice 线程状态分布 | `slices.time_in_state`, `sched.states` |
| `input.py` | `InputMixin` | `collect_input_latency()` — 输入事件延迟分解 | `android.input` |
| `sched_latency.py` | `SchedLatencyMixin` | `collect_sched_latency()` — 调度延迟分析 | `sched.latency` |
| `oom.py` | `OomMixin` | `collect_oom_rss_swap()` — OOM score 转换 + RSS/Swap + LMK 事件 | `android.memory.process`, `android.memory.lmk` |
| `cpu_utilization.py` | `CpuUtilizationMixin` | `collect_process_cpu_utilization()` — 进程级 CPU 利用率 | `linux.cpu.utilization.process` |
| `cpu_utilization.py` | `CpuUtilizationMixin` | `collect_thread_cpu_utilization()` — 线程级 CPU 利用率 | `linux.cpu.utilization.thread` |
| `surfaceflinger.py` | `SurfaceFlingerMixin` | `collect_surfaceflinger_timeline()` — App-SF 帧时间线匹配 | `android.surfaceflinger` |

### 添加新 Stdlib 模块的约定

1. 在 `src/smartinspector/collector/` 下创建新文件,以 Mixin 模式实现
2. 类名遵循 `{Feature}Mixin` 命名
3. 方法名遵循 `collect_{metric_name}()` 命名,返回 `list[dict]` 或 `dict`
4. SQL 查询中使用 `INCLUDE PERFETTO MODULE {module_path};` 引入 stdlib
5. 在 `PerfettoCollector` 中通过多重继承挂载 Mixin
6. 查询结果按耗时/大小降序排列,使用 `LIMIT` 控制返回数量
Loading
Loading