--- id: wiki-2026-0508-orinoco title: Orinoco (V8 GC project) category: 10_Wiki/Topics status: verified canonical_id: self aliases: [V8 Orinoco, Orinoco GC, Concurrent V8 GC] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [v8, gc, performance, concurrent-marking, runtime] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: cpp framework: v8 --- # Orinoco ## 매 한 줄 > **"매 V8의 GC를 stop-the-world에서 incremental · concurrent · parallel multi-threaded GC로 전환한 multi-year 프로젝트."**. 2016년 시작, 2017-2019 Concurrent Marking · Parallel Scavenger · Lazy Sweeping 차례 도입. 2026 현재 V8 13.x base GC architecture가 Orinoco — pause time을 100ms+ → <1ms로 감소. ## 매 핵심 ### 매 핵심 기법 - **Parallel Scavenger** (Young Gen): 매 multiple worker가 semi-space copy 병렬화. - **Concurrent Marking** (Old Gen): 매 worker thread가 mutator와 병행 mark — main thread는 거의 미 pause. - **Incremental Marking**: 매 mark phase를 여러 작은 chunk로 나눔. - **Parallel/Concurrent Compaction**: page별 evacuation 병렬화. - **Lazy Sweeping**: 매 sweep을 allocation 시점까지 지연. - **Black Allocation**: 매 marking 중 새 alloc은 black (skip). ### 매 write barrier 역할 - 매 mutator가 마크된 object → 비마크 object 참조 추가 시 dirty card 표시. - 매 concurrent marker가 stale graph 처리. ### 매 응용 1. Chrome — main thread jank 감소, smooth 60fps scroll. 2. Node.js — large heap server에서 long pause 제거. 3. Electron/VSCode — GUI responsiveness 유지. ## 💻 패턴 ### Orinoco effect 측정 (Node.js) ```bash # Major GC pause 분포 node --trace-gc --trace-gc-verbose app.js 2>&1 \ | grep "Mark-" | awk '{print $5}' \ | sort -n | uniq -c # 2026 V8: 대부분 < 1ms, occasional 5ms ``` ### Disable concurrent marking (compare) ```bash node --no-concurrent-marking --trace-gc app.js # pause time 명백히 증가 (10-50ms 종종) ``` ### Per-isolate GC stats ```javascript import { getHeapStatistics } from 'node:v8'; const before = getHeapStatistics(); heavyWorkload(); const after = getHeapStatistics(); console.log('major_gc count:', after.number_of_native_contexts); console.log('used:', (after.used_heap_size - before.used_heap_size) / 1e6, 'MB'); ``` ### Performance.measureUserAgentSpecificMemory (Chrome) ```javascript // In Chrome with COOP+COEP if (performance.measureUserAgentSpecificMemory) { const result = await performance.measureUserAgentSpecificMemory(); console.log(result.bytes, result.breakdown); } ``` ### Reduce concurrent-marking pressure ```javascript // Avoid: huge graph mutation in tight loop function reseat(arr, n) { for (let i = 0; i < n; i++) arr[i] = { ref: arr[(i+1) % n] }; // many write barriers → marker work spike } // Prefer: build once, freeze const frozen = Object.freeze(buildGraph()); ``` ### Inspect GC marking phase via perf_hooks ```javascript import { PerformanceObserver } from 'node:perf_hooks'; const obs = new PerformanceObserver(list => { for (const e of list.getEntriesByType('gc')) { if (e.detail.kind === 2 /* MARK_SWEEP_COMPACT */) console.log('major GC:', e.duration.toFixed(2), 'ms'); } }); obs.observe({ entryTypes: ['gc'] }); ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Long pause complaint (UI jank) | check Orinoco enabled (default), profile | | Embedded V8 (custom flags) | enable concurrent + incremental marking | | Constrained memory (IoT) | might disable concurrent (extra worker thread) | | Benchmarking | report w/ default flags + GC trace | **기본값**: 매 default flags (Orinoco on) — 매 manual disable 회피. ## 🔗 Graph - 부모: [[Garbage_Collection]] · [[V8 엔진 힙 아키텍처|V8 Heap Architecture]] - 변형: [[Incremental_Marking]] · [[Concurrent_Marking]] · [[Mark-Sweep]] - 응용: [[Old_Space]] · [[Pointer_Compression]] · [[Write Barrier|Write_Barrier]] - Adjacent: [[Generational_Hypothesis]] · [[Snapshots]] · [[Multi-threaded Architecture]] ## 🤖 LLM 활용 **언제**: V8 GC internals 학습, Node.js/Chrome perf 분석, GC pause 회귀 추적. **언제 X**: non-V8 runtime (Hermes는 별도 GC), Java/Go GC (G1/ZGC/Shenandoah는 다른 design). ## ❌ 안티패턴 - **Disabling concurrent marking blindly**: 매 measurement 없이 — 보통 perf 악화. - **Huge mutation in hot loop**: 매 write barrier overload. - **Forcing `global.gc()` 빈번**: 매 production 절대 X — Orinoco가 알아서 함. - **Confusing minor (scavenge) and major (mark-sweep)**: 매 trace 해석 오류. ## 🧪 검증 / 중복 - Verified (V8 blog "Orinoco" series 2016-2019, V8 source `src/heap/`, Mathias Bynens & Benedikt Meurer talks 2017-2020). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — Orinoco GC project (concurrent/parallel/incremental) |