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 폴더 제거.
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
---
|
||||
id: wiki-2026-0508-pointer-compression
|
||||
title: Pointer Compression
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [V8 pointer compression, compressed pointers, 32-bit pointers in 64-bit heap]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [v8, javascript-engine, memory, optimization]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: cpp
|
||||
framework: v8
|
||||
---
|
||||
|
||||
# Pointer Compression
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 64-bit 시스템 위에서 heap pointer를 32-bit 로 줄여 절반 공간으로 저장"**. 매 V8(2020), Hermes, JVM(CompressedOops, 2008부터) 의 heap memory ~40% 절감 + 매 cache locality 향상. 매 4GB 안 heap 제한 대신 매 typical web app 에는 충분.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 동기
|
||||
- 매 64-bit OS 의 V8 heap object 의 80% 가 pointer field 차지.
|
||||
- 매 pointer = 매 8 bytes 인데 실제 정보 entropy ~32 bits (heap < 4GB).
|
||||
- 매 절반으로 → 매 RAM↓, 매 GC scan 시간 ↓, 매 L1/L2 cache hit ↑.
|
||||
|
||||
### 매 V8 scheme (post-2020)
|
||||
- **Cage**: 매 4GB 정렬된 가상 메모리 reservation.
|
||||
- **Base register / R13**: 매 cage base 주소 보관 (cached).
|
||||
- **32-bit slot**: 매 cage 안 offset.
|
||||
- **Smi tagging**: 매 31-bit integer 의 inline (1 LSB tag).
|
||||
- **Decompress**: `addr = base + (int64_t)(int32_t)compressed`.
|
||||
|
||||
### 매 trade-off
|
||||
- **+** Heap mem ~30–43% 절감, 매 V8 startup ↓.
|
||||
- **+** Cache pressure ↓ → 매 throughput 5-10% ↑.
|
||||
- **−** Per-access decompression cost (매 작음, 보통 +1 ALU).
|
||||
- **−** Heap 4GB 한계 (매 큰 app 의 큰 process 분할 필요).
|
||||
- **−** External pointer 는 sandboxed pointer table 로 indirection 추가.
|
||||
|
||||
### 매 비슷한 system
|
||||
- **JVM CompressedOops**: 매 8-byte aligned + shift → 매 32GB heap 까지 32-bit.
|
||||
- **CHERI capabilities**: 매 다른 방향 — 매 capability + bounds 로 fat pointer.
|
||||
- **Hermes (RN)**: 매 32-bit pointer + handle table.
|
||||
- **WebAssembly memory64 vs memory32**: 매 동일 motif.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Compress / decompress (V8 conceptual)
|
||||
```cpp
|
||||
// 매 V8 cage base = 4GB-aligned
|
||||
inline Address Decompress(uint32_t compressed, Address cage_base) {
|
||||
return cage_base + static_cast<int64_t>(static_cast<int32_t>(compressed));
|
||||
}
|
||||
|
||||
inline uint32_t Compress(Address full) {
|
||||
return static_cast<uint32_t>(full); // 매 lower 32 bits
|
||||
}
|
||||
|
||||
// 매 Smi (Small Integer) tagging
|
||||
constexpr int kSmiTagSize = 1;
|
||||
inline bool IsSmi(uint32_t v) { return (v & 1) == 0; }
|
||||
inline int32_t SmiValue(uint32_t v) { return static_cast<int32_t>(v) >> 1; }
|
||||
```
|
||||
|
||||
### Tagged slot in heap object
|
||||
```cpp
|
||||
class HeapObject {
|
||||
uint32_t map_; // 매 type info, compressed
|
||||
uint32_t properties_; // 매 compressed
|
||||
uint32_t elements_; // 매 compressed
|
||||
// 매 instance fields follow, all 4 bytes each
|
||||
};
|
||||
// 매 compare: 64-bit pointer system 에서 same object = 24 bytes header
|
||||
```
|
||||
|
||||
### JVM CompressedOops
|
||||
```bash
|
||||
# 매 default ON when heap ≤ 32GB on 64-bit JVM
|
||||
java -XX:+UseCompressedOops -Xmx16g App
|
||||
# 매 8-byte alignment + 3-bit shift → 매 32-bit reference 가 32GB 까지 cover
|
||||
java -XX:ObjectAlignmentInBytes=8 ...
|
||||
```
|
||||
|
||||
### Sandboxed external pointers (V8 2024+)
|
||||
```cpp
|
||||
// 매 untrusted external ptr → 매 indirection table
|
||||
class ExternalPointerTable {
|
||||
Address entries_[N];
|
||||
public:
|
||||
uint32_t Allocate(Address external) {
|
||||
uint32_t handle = next_++;
|
||||
entries_[handle] = external;
|
||||
return handle; // 매 store handle 32-bit, not raw ptr
|
||||
}
|
||||
Address Resolve(uint32_t handle) { return entries_[handle]; }
|
||||
};
|
||||
```
|
||||
|
||||
### Disable pointer compression (V8 build)
|
||||
```bash
|
||||
# 매 large heap (>4GB) needed
|
||||
gn args out.gn/x64.release
|
||||
# v8_enable_pointer_compression = false
|
||||
ninja -C out.gn/x64.release v8
|
||||
```
|
||||
|
||||
### Hermes 32-bit handle (React Native)
|
||||
```cpp
|
||||
// 매 HermesValue = 64-bit NaN-boxed; pointer 부분은 cage offset 32-bit
|
||||
struct HermesValue {
|
||||
uint64_t raw;
|
||||
bool isPointer() const { return (raw & kTagMask) == kPointerTag; }
|
||||
HeapPtr getPointer() const { return base_ + (raw & kPayloadMask); }
|
||||
};
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Browser tab / Node ≤ 4GB | V8 pointer compression ON (default) |
|
||||
| Large server-side V8 (>4GB) | Compile with compression OFF or use isolates |
|
||||
| JVM ≤ 32GB heap | CompressedOops ON (default) |
|
||||
| JVM > 32GB | UseCompressedOops auto-OFF |
|
||||
| Mobile JS (Hermes) | Always 32-bit handle |
|
||||
| Custom GC engine | 매 cage allocator + tagged 4-byte slot 직접 구현 |
|
||||
|
||||
**기본값**: 매 modern engine 의 default ON; 매 disable 은 명백한 large-heap 이유 있을 때만.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Garbage Collection]]
|
||||
- 응용: [[V8]] · [[Hermes]] · [[Chromium]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 V8/JVM/JS-engine 의 heap memory profiling. 매 mobile/tab memory pressure.
|
||||
**언제 X**: 매 native-only (Rust/C++) 의 단순 64-bit pointer — 매 자체 GC 없으면 의미 적음.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **>4GB V8 heap with compression ON**: 매 OOM crash. 매 isolate 분할 또는 disable.
|
||||
- **Misaligned cage**: 매 4GB align 안 되면 decompress 산술 깨짐.
|
||||
- **External raw pointer in heap**: 매 sandbox bypass + crash on heap relocation. → 매 external pointer table 필수.
|
||||
- **Assumption that pointer = 8 bytes** in tooling: 매 V8 inspector / heap snapshot tools 가 가정 하면 corrupt read.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (V8 blog "Pointer Compression in V8" 2020, JVM CompressedOops docs, Hermes design doc).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — V8 cage scheme + CompressedOops + sandboxed external |
|
||||
Reference in New Issue
Block a user