f8b21af4be
10_Wiki/Topics 대규모 정리: - 오류 캡처/미완성 stub 문서 227개 제거 - 교차폴더 중복 43클러스터 병합 (63파일 → redirect) - 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건 - 카테고리 MOC 6개 신규 생성 - Graph 섹션 미해결 related-keyword 링크 10,058건 제거 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4.8 KiB
4.8 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-efficiency | Efficiency | 10_Wiki/Topics | verified | self |
|
none | A | 0.88 | applied |
|
2026-05-10 | pending |
|
Efficiency
매 한 줄
"매 useful output / resource consumed — 매 latency, throughput, $cost, watt 매 dimension 별 측정". 매 1972 Knuth "premature optimization" warning 후 신중함이 default, 매 2026 cloud cost + carbon footprint + energy efficiency 가 first-class metric.
매 핵심
매 Efficiency dimensions
- Time: latency p50/p95/p99, throughput RPS.
- Space: memory RSS, disk IOPS, network bytes.
- Money: $/request, $/MAU.
- Energy: watt/op, gCO2eq/request.
매 측정 → 개선 cycle
- Profile: hotspot 의 identify (flamegraph).
- Hypothesize: bottleneck 의 type (CPU? IO? Lock?).
- Optimize: targeted change.
- Verify: A/B with baseline, metric 의 statistical sig.
매 응용
- API: cold-start 의 reduce.
- ML inference: quantization, batching, KV cache.
- CI: cache hit rate 의 maximize.
💻 패턴
Latency histogram (Prometheus)
from prometheus_client import Histogram
LATENCY = Histogram('http_request_duration_seconds', 'HTTP latency',
buckets=[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5])
@LATENCY.time()
def handle(req): ...
Cost-per-request rollup
-- BigQuery
SELECT
service,
SUM(billable_seconds * cpu_cost_per_sec) AS compute_usd,
COUNT(*) AS requests,
SUM(billable_seconds * cpu_cost_per_sec) / COUNT(*) AS usd_per_req
FROM service_metrics
WHERE _PARTITIONDATE = CURRENT_DATE() - 1
GROUP BY service
ORDER BY usd_per_req DESC;
CPU flamegraph (py-spy)
# 매 production-safe sampling profiler
py-spy record -o flame.svg -d 60 -p $(pgrep -f gunicorn)
py-spy top -p $(pgrep -f gunicorn)
Memory profiling (memray)
memray run --live ./app.py
memray flamegraph output.bin -o memflame.html
Async IO efficiency
import asyncio, httpx
# BAD — sequential
async def fetch_seq(urls):
async with httpx.AsyncClient() as c:
return [await c.get(u) for u in urls]
# GOOD — concurrent
async def fetch_par(urls):
async with httpx.AsyncClient() as c:
return await asyncio.gather(*[c.get(u) for u in urls])
Carbon-aware scheduling
import httpx
async def carbon_intensity(region: str) -> float:
r = await httpx.AsyncClient().get(
f"https://api.electricitymaps.com/v3/carbon-intensity/latest?zone={region}",
headers={"auth-token": "TOKEN"})
return r.json()["carbonIntensity"] # gCO2eq/kWh
# 매 batch job 매 low-carbon window 의 schedule
async def maybe_run(region):
ci = await carbon_intensity(region)
if ci < 200: await run_batch()
else: await asyncio.sleep(900)
LLM inference batching
from vllm import LLM, SamplingParams
llm = LLM(model="meta-llama/Llama-3.3-70B-Instruct",
tensor_parallel_size=4,
max_num_seqs=256) # 매 batch 의 throughput
sp = SamplingParams(max_tokens=256)
outs = llm.generate(prompts, sp) # 매 single forward pass 로 batch
Cache efficiency dashboard
# Prometheus query — cache hit ratio
sum(rate(cache_hits_total[5m])) /
(sum(rate(cache_hits_total[5m])) + sum(rate(cache_misses_total[5m])))
매 결정 기준
| 상황 | Approach |
|---|---|
| Latency-critical (real-time) | tail-latency optimize, drop p99 outliers |
| Throughput (batch) | parallelism, vectorize |
| Cost 제약 | spot instance, autoscale, cache |
| Green ops | carbon-aware scheduling, region selection |
기본값: 매 profile-first, 매 measure both before/after, 매 single-dimension fixation 매 X.
🔗 Graph
- 부모: Site Reliability Engineering
- 변형: Latency
- 응용: Flame_Graphs · Profiling
- Adjacent: FinOps · Green Software
🤖 LLM 활용
언제: profile output → bottleneck classification, optimization 후보 ranking. 언제 X: 매 micro-benchmark 매 LLM 의 single-shot 평가 X — 매 측정 우선.
❌ 안티패턴
- Premature optimization: profile 없이 optimize.
- Single-metric obsession: latency 만 보고 cost 폭증.
- Synthetic benchmark: production traffic shape 무시.
- No baseline: 매 before 측정 없이 "fast" 주장.
🧪 검증 / 중복
- Verified (SRE Workbook ch.4, AWS Well-Architected Performance pillar).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — efficiency 4 dimension + measurement loop |