Files
2nd/10_Wiki/Topic_Programming/Coding/Native_Perf_Tracing_Systrace.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

4.1 KiB

id, title, category, status, source_trust_level, verification_status, created_at, updated_at, tags, tech_stack, applied_in, aliases
id title category status source_trust_level verification_status created_at updated_at tags tech_stack applied_in aliases
native-perf-tracing-systrace Native Perf Tracing — Systrace / Instruments / Perfetto Coding draft B conceptual 2026-05-09 2026-05-09
native
performance
systrace
perfetto
instruments
vibe-coding
language applicable_to
Swift / Kotlin
iOS
Android
Systrace
Perfetto
Instruments Time Profiler
frame timing
trace

Native Perf Tracing

Frame drop / startup 느림 / scroll jank 분석 = trace tool. Android: Perfetto / Systrace. iOS: Instruments (Time Profiler / SwiftUI / Animation Hitches). Custom span 으로 본인 코드도 표시.

📖 핵심 개념

  • Frame budget: 60fps = 16.6ms / 120fps = 8.3ms.
  • Jank: budget 초과 = 사용자 보임.
  • Trace: 시간축 위 함수 실행 그래프.
  • Custom span: 라이브러리 / 본인 함수 표시.

💻 코드 패턴

Android — Perfetto (modern)

# Android Studio: Profiler → System Trace
# 또는 명령행:
adb shell perfetto --txt -c - --out /data/misc/perfetto-traces/trace -t 10s sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory <<< ''

Custom trace section (Android)

import androidx.tracing.Trace

Trace.beginSection("loadHomeFeed")
val items = repo.loadFeed()
Trace.endSection()

// 또는 inline
Trace.beginAsyncSection("download:image:42", 42)
download(url) { Trace.endAsyncSection("download:image:42", 42) }

iOS — Instruments

Xcode → Product → Profile (⌘I) →
- Time Profiler: 시간 소요 함수
- Animation Hitches: 60fps 깬 frame
- SwiftUI: View 재계산
- Network: 요청 latency
- Allocations: 메모리

iOS — os_signpost (custom span)

import os.signpost

let log = OSLog(subsystem: "com.app", category: .pointsOfInterest)
let id = OSSignpostID(log: log)

os_signpost(.begin, log: log, name: "loadFeed", signpostID: id)
let items = await loadFeed()
os_signpost(.end, log: log, name: "loadFeed", signpostID: id)

Instruments → os_signpost instrument 추가하면 timeline 에 보임.

Frame timing (iOS)

let displayLink = CADisplayLink(target: self, selector: #selector(tick))
displayLink.add(to: .main, forMode: .common)

@objc func tick(_ dl: CADisplayLink) {
    let frameDuration = dl.targetTimestamp - dl.timestamp
    if frameDuration > 1.0 / 60.0 + 0.005 { print("hitch") }
}

Frame timing (Android)

Choreographer.getInstance().postFrameCallback(object : FrameCallback {
    var last = 0L
    override fun doFrame(now: Long) {
        if (last > 0) {
            val ms = (now - last) / 1_000_000
            if (ms > 16) Log.d("frame", "jank $ms ms")
        }
        last = now
        Choreographer.getInstance().postFrameCallback(this)
    }
})

App startup tracing

// AndroidX Startup Initializer 또는 manual
class App : Application() {
    override fun onCreate() {
        Trace.beginSection("App.onCreate")
        super.onCreate()
        // ...
        Trace.endSection()
    }
}

🤔 의사결정 기준

분석 대상 도구
Scroll jank Systrace/Perfetto + Choreographer (Android) / Instruments Animation Hitches (iOS)
Cold startup Systrace boot to firstFrame / iOS Launch Time
함수 hot path Time Profiler (iOS) / CPU Profiler (Android)
사용자 본인 함수 표시 Trace.beginSection / os_signpost
네트워크 latency Charles / 본인 SDK observability

안티패턴

  • Trace section 안 닫음: timeline 깨짐.
  • Profile build 안 씀: debug 는 느림 — release 또는 profile build 사용.
  • profile 상태 의존: profiler attach 자체가 영향. 상대 비교만.
  • 시작 측정 — emulator 만: 실기와 다름.
  • 로그로 시간 측정: I/O 자체가 시간. 표시 적은 trace API.
  • 첫 측정만 보기: warm-up 필요. 5번 평균.

🤖 LLM 활용 힌트

  • iOS = os_signpost + Instruments. Android = Trace + Perfetto.
  • Frame budget 16.6ms 기준 비교.

🔗 관련 문서