Files
2nd/10_Wiki/Topics/DevOps_and_Security/Analyze runtime performance.md
T
2026-05-10 22:08:15 +09:00

4.6 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-analyze-runtime-performance Analyze runtime performance 10_Wiki/Topics verified self
Performance Analysis
Profiling
Runtime Profiling
none A 0.9 applied
profiling
performance
devtools
2026-05-10 applied
language framework
JavaScript/Python Chrome DevTools/perf/py-spy

Analyze runtime performance

매 한 줄

"매 측정 없이 최적화 없다.". Runtime performance 분석은 sampling profiler + tracing + flame graph + RAIL/Web Vitals metrics 의 stack 으로 매 hot path 와 long task 를 식별. 2026 stack: Chrome Performance panel (Insights AI), perf+FlameGraph, py-spy, eBPF/bpftrace, Datadog APM.

매 핵심

매 Profiler Type

  • Sampling: 매 N ms 마다 stack 캡처 — 매 low overhead, statistical (perf, py-spy, async-profiler).
  • Instrumentation: 매 fn enter/exit 기록 — 매 accurate, high overhead.
  • Tracing: 매 event timeline (Chrome trace, perfetto).
  • Hardware counters: PMU — IPC, cache miss, branch miss.

매 RAIL Model (web)

  • Response: < 100ms input → feedback.
  • Animation: < 16ms / frame (60fps).
  • Idle: 50ms work blocks max.
  • Load: < 5s on 4G.

매 Core Web Vitals 2026

  • LCP (Largest Contentful Paint) < 2.5s.
  • INP (Interaction to Next Paint) < 200ms — 매 FID 대체 (2024+).
  • CLS (Cumulative Layout Shift) < 0.1.

매 응용

  1. Web app TTI/INP 개선.
  2. Backend p99 latency 추적.
  3. Game/XR frame budget.
  4. ML inference latency.
  5. CI pipeline 시간 단축.

💻 패턴

Chrome Performance panel + AI insights

// 매 manual marker — show up in Performance timeline
performance.mark('ai-search:start');
const r = await search(q);
performance.mark('ai-search:end');
performance.measure('ai-search', 'ai-search:start', 'ai-search:end');
// 매 record trace in DevTools → AI Insights highlights bottleneck (2025+)

User Timing API + reporter

const obs = new PerformanceObserver(list => {
  list.getEntries().forEach(e => analytics('perf', { name: e.name, dur: e.duration }));
});
obs.observe({ entryTypes: ['measure', 'navigation', 'resource', 'longtask'] });

py-spy live flame graph

# 매 attach to running PID, no code change
py-spy record -o flame.svg --pid 12345 --duration 30
# 매 live top-like
py-spy top --pid 12345

Linux perf flame graph

sudo perf record -F 99 -g -p $PID -- sleep 30
sudo perf script | \
  ./stackcollapse-perf.pl | ./flamegraph.pl > flame.svg

Web Vitals INP measurement

import { onINP, onLCP, onCLS } from 'web-vitals';
onINP(m => beacon('inp', m.value, m.id));
onLCP(m => beacon('lcp', m.value, m.id));
onCLS(m => beacon('cls', m.value, m.id));

Node --prof + --prof-process

node --prof server.js
# 매 after run
node --prof-process isolate-*.log > profile.txt

eBPF (bpftrace) syscall latency

sudo bpftrace -e '
  tracepoint:syscalls:sys_enter_read { @s[tid] = nsecs; }
  tracepoint:syscalls:sys_exit_read /@s[tid]/ {
    @us = hist((nsecs - @s[tid]) / 1000);
    delete(@s[tid]);
  }'

매 결정 기준

상황 Tool
Web (Chromium) DevTools Performance + Web Vitals
Node.js clinic.js / 0x / --prof
Python py-spy / scalene / cProfile
JVM async-profiler / JFR
Go pprof
Linux native perf + FlameGraph / eBPF
Production APM Datadog / NewRelic / OTel

기본값: 매 sampling profiler 우선, instrumentation 은 spot-check.

🔗 Graph

🤖 LLM 활용

언제: flame graph 해석, perf insight 요약, regression hypothesis. 언제 X: 매 nanosecond-level profiling — specialized tool 만이 정확.

안티패턴

  • Production 에 instrumenting profiler: 매 overhead 폭발.
  • Single-run 결론: 매 statistical noise — multi-run 필요.
  • Average only: 매 p50 보다 p99 가 user 체감.
  • Profile dev build: 매 prod build 와 다름 — release/optimized 측정.

🧪 검증 / 중복

  • Verified: web.dev Performance docs; Brendan Gregg "Systems Performance"; Chrome DevTools docs.
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — RAIL/INP + multi-language profilers