c24165b8bc
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6.3 KiB
6.3 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-쓰기-장벽-write-barrier | 쓰기 장벽(Write Barrier) | 10_Wiki/Topics | verified | self |
|
none | A | 0.95 | applied |
|
2026-05-10 | pending |
|
쓰기 장벽(Write Barrier)
매 한 줄
"매 reference store 시 GC 가 끼어드는 hook". 매 generational / concurrent GC 의 핵심 mechanism — 매 mutator 가 pointer 를 쓸 때마다 매 GC metadata 를 업데이트하여 매 cross-generation reference 추적 + concurrent marking 의 invariant 유지. 2026 년 모든 modern GC (G1, ZGC, Shenandoah, V8 Orinoco, Go GC) 매 필수.
매 핵심
매 정의
- 매
obj.field = refinstruction 시 매 runtime-injected code. - 매 compiler 가 매 store 직전/직후 hook 삽입.
- 매 cost: 매 native pointer write 의 1.05x ~ 1.3x.
매 종류
- Card marking: 매 heap 을 card (보통 512B) 단위로 분할 — 매 dirty bit 표시.
- Remembered set (RSet): 매 region 별 incoming reference list.
- SATB (Snapshot-At-The-Beginning): 매 G1/Shenandoah — 매 마킹 시작 시 graph snapshot.
- Incremental update: 매 CMS 류 — 매 새로 추가된 reference 추적.
- Dijkstra-style: 매 black-to-white reference 차단 (Go).
매 응용
- Generational GC — 매 old → young reference 추적.
- Concurrent marking — 매 mutator-collector race 방지.
- Region-based GC (G1, ZGC) — 매 cross-region reference RSet.
💻 패턴
Card marking (HotSpot CMS/G1)
// 매 conceptual code — 매 HotSpot 의 oop_store
inline void oop_store(oop* field, oop new_val) {
*field = new_val; // 매 actual write
// 매 post-write barrier
uintptr_t card_index = ((uintptr_t)field) >> CARD_SHIFT; // 매 9 = 512B
card_table[card_index] = DIRTY; // 매 매 single byte write
}
// 매 minor GC 시 매 dirty card 만 scan — 매 old gen 전체 X
void scan_dirty_cards_for_young_refs() {
for (auto i = 0; i < card_count; i++) {
if (card_table[i] == DIRTY) {
scan_card_for_young_pointers(i);
card_table[i] = CLEAN;
}
}
}
G1 RSet (remembered set)
// 매 region 별 incoming reference 추적
class HeapRegion {
PerRegionTable rset; // 매 다른 region 의 어디가 매 나를 가리키는지
void update_rset(oop* from_field, oop to_obj) {
if (region_of(from_field) != this) {
rset.add(card_of(from_field));
}
}
};
// 매 evacuation 시 RSet scan — 매 외부 reference rewrite
SATB write barrier (Shenandoah/G1 concurrent mark)
// 매 pre-write barrier — 매 old value 를 매 marking queue 에 push
inline void satb_oop_store(oop* field, oop new_val) {
if (concurrent_marking_active) {
oop old_val = *field;
if (old_val != nullptr && !is_marked(old_val)) {
satb_queue.push(old_val); // 매 snapshot 보존
}
}
*field = new_val;
}
// 매 invariant: 매 marking 시작 시점의 graph 가 매 모두 visit
V8 incremental marking (Dijkstra-style)
// 매 black-to-white reference 차단
inline void v8_write_barrier(HeapObject* host, Object** slot, Object* value) {
if (!is_incremental_marking) {
*slot = value;
return;
}
if (Marking::IsBlack(host) && Marking::IsWhite(value)) {
// 매 violation — 매 white 를 grey 로
marking_worklist.push(value);
Marking::WhiteToGrey(value);
}
*slot = value;
}
Go GC hybrid barrier (Yuasa + Dijkstra)
// 매 runtime/mbarrier.go 의 conceptual
//go:nosplit
func writebarrierptr(slot **byte, val *byte) {
// 매 hybrid: 매 deletion + insertion barrier 결합
if writeBarrier.enabled {
old := *slot
if old != nil { shade(old) } // 매 Yuasa (deletion)
if val != nil { shade(val) } // 매 Dijkstra (insertion)
}
*slot = val
}
func shade(p *byte) {
obj := findObject(p)
if obj != nil && !marked(obj) {
markGrey(obj)
gcWork.push(obj)
}
}
Compiler intrinsic (LLVM/HotSpot)
// 매 JIT 가 매 oop_store 호출 매 inline expand
// 매 "object.field = ref" 매 compile 결과:
// 1. mov [rax+offset], rbx ; 매 actual store
// 2. shr rax, 9 ; 매 card index
// 3. mov byte [card_table + rax], 0 ; 매 mark dirty
// 매 cost: 매 3 instructions, 매 ~1ns
매 결정 기준
| GC type | Barrier 종류 |
|---|---|
| Generational (young/old) | Card marking + RSet |
| Concurrent marking (G1, Shenandoah) | SATB pre-barrier |
| Incremental (V8 Orinoco) | Dijkstra post-barrier |
| Region-based evacuation (G1, ZGC) | Card marking + RSet + SATB |
| Go GC | Hybrid (Yuasa + Dijkstra) |
| Reference counting | Increment/decrement barrier |
기본값: 매 modern multi-threaded GC 매 hybrid barrier — 매 SATB + card marking 결합.
🔗 Graph
- 부모: Garbage Collection · Memory Management
- 응용: V8 Orinoco
- Adjacent: Tri-color Marking · Concurrent Marking
🤖 LLM 활용
언제: 매 GC 동작 분석, 매 GC overhead 측정, 매 custom runtime 설계, 매 JIT compiler 최적화. 언제 X: 매 application-level memory tuning (매 heap size 조정 만 — 매 barrier internal 무관).
❌ 안티패턴
- Manual barrier elision: 매 "이 store 는 안전" 자체 판단 매 elision — 매 GC invariant 파괴.
- Card size 무관 micro-tune: 매 application 매 card size 변경 — 매 runtime config 영역 X.
- Barrier ignore in JNI: 매 native code 가 매 barrier bypass 하여 oop write — 매 dangling reference.
- Concurrent marking 중 atomic operation 무시: 매 race condition.
🧪 검증 / 중복
- Verified (Jones et al. "The Garbage Collection Handbook" 2nd ed, HotSpot source code, V8 design docs, Go runtime source).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — barrier 종류별 패턴 + runtime examples |