chore(brain): ASTRA 성장 자산 동기화 — 기능 인벤토리·growth(약점프로필/학습큐)·일화기억·장기기억·회의록 원문
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
---
|
||||
id: wiki-2026-0508-snapshots
|
||||
title: Snapshots
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [State Snapshot, V8 Snapshot, GC Snapshot, Heap Snapshot]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [runtime, performance, debugging, memory, state]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: javascript
|
||||
framework: v8
|
||||
---
|
||||
|
||||
# Snapshots
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 point-in-time 의 state freeze — 매 startup 의 accelerate, 매 leak 의 hunt, 매 recovery 의 enable."**. 매 V8 startup snapshot, heap snapshot, filesystem snapshot (ZFS/Btrfs), DB snapshot, state snapshot (Redux time-travel) — 매 same primitive 의 different domain. 매 modern runtime 의 cold-start optimization 의 default tool.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 종류
|
||||
- **V8 startup snapshot**: serialize heap → fast Node.js cold start.
|
||||
- **Heap snapshot** (`.heapsnapshot`): debug memory leak, retainer graph.
|
||||
- **GC snapshot**: generational scan checkpoint.
|
||||
- **Filesystem snapshot**: ZFS/Btrfs/LVM copy-on-write point-in-time.
|
||||
- **DB snapshot**: PITR base, transactional checkpoint.
|
||||
- **State snapshot**: Redux DevTools time-travel, game save.
|
||||
|
||||
### 매 properties
|
||||
- Copy-on-write (efficient diff storage).
|
||||
- Atomic (consistent point-in-time).
|
||||
- Restorable (full state reconstruction).
|
||||
- Immutable (snapshot itself never mutated).
|
||||
|
||||
### 매 응용
|
||||
1. Node.js bootup `--snapshot-blob` (200ms → 30ms startup).
|
||||
2. Chrome DevTools heap profiler — leak hunt.
|
||||
3. ZFS rollback before risky deploy.
|
||||
4. Postgres PITR base + WAL replay.
|
||||
5. Redux DevTools — time-travel debug.
|
||||
6. AWS EBS snapshot — disaster recovery.
|
||||
7. Container checkpoint/restore (CRIU).
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Node.js startup snapshot
|
||||
```bash
|
||||
node --snapshot-blob snapshot.blob --build-snapshot snapshot-init.js
|
||||
node --snapshot-blob snapshot.blob app.js
|
||||
# Cold start: 200ms → ~30ms
|
||||
```
|
||||
|
||||
### Chrome heap snapshot programmatic
|
||||
```javascript
|
||||
const v8 = require('v8');
|
||||
const fs = require('fs');
|
||||
const stream = v8.getHeapSnapshot();
|
||||
stream.pipe(fs.createWriteStream('heap.heapsnapshot'));
|
||||
// Open in Chrome DevTools → Memory tab
|
||||
```
|
||||
|
||||
### ZFS snapshot + rollback
|
||||
```bash
|
||||
zfs snapshot tank/data@before-deploy
|
||||
# ... risky operation ...
|
||||
zfs rollback tank/data@before-deploy # if failure
|
||||
zfs destroy tank/data@before-deploy # if success
|
||||
```
|
||||
|
||||
### Postgres base backup + PITR
|
||||
```bash
|
||||
pg_basebackup -D /backup/base -F tar -X stream -P
|
||||
# Recover to point-in-time
|
||||
restore_command = 'cp /archive/%f %p'
|
||||
recovery_target_time = '2026-05-10 14:30:00'
|
||||
```
|
||||
|
||||
### Redux state snapshot
|
||||
```typescript
|
||||
import { createStore } from 'redux';
|
||||
const store = createStore(reducer);
|
||||
|
||||
const snapshot = store.getState(); // freeze
|
||||
// ... actions ...
|
||||
store.replaceReducer((state = snapshot) => state); // restore
|
||||
```
|
||||
|
||||
### CRIU container checkpoint
|
||||
```bash
|
||||
criu dump --tree $PID --images-dir /checkpoints/svc-1 --leave-running
|
||||
# Later, possibly on different host:
|
||||
criu restore --images-dir /checkpoints/svc-1
|
||||
```
|
||||
|
||||
### EBS snapshot via AWS SDK
|
||||
```typescript
|
||||
import { EC2Client, CreateSnapshotCommand } from '@aws-sdk/client-ec2';
|
||||
|
||||
await client.send(new CreateSnapshotCommand({
|
||||
VolumeId: 'vol-0abc',
|
||||
Description: 'pre-migration-2026-05-10',
|
||||
TagSpecifications: [{ ResourceType: 'snapshot', Tags: [{ Key: 'env', Value: 'prod' }] }],
|
||||
}));
|
||||
```
|
||||
|
||||
### Heap diff analysis
|
||||
```javascript
|
||||
// Take 2 snapshots, diff in DevTools to find leak
|
||||
v8.writeHeapSnapshot('/tmp/before.heapsnapshot');
|
||||
runSuspectCode();
|
||||
v8.writeHeapSnapshot('/tmp/after.heapsnapshot');
|
||||
// Load both → "Comparison" view → growing retainer chains
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Node.js cold start slow | startup snapshot |
|
||||
| Memory leak hunt | heap snapshot diff |
|
||||
| Pre-deploy rollback safety | ZFS/EBS snapshot |
|
||||
| DB recovery to time T | PITR base + WAL |
|
||||
| Container live migration | CRIU checkpoint |
|
||||
| Frontend bug repro | Redux time-travel |
|
||||
|
||||
**기본값**: heap snapshot for leaks, ZFS/EBS for storage, PITR for DB, CRIU for container.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[State-Management]]
|
||||
- 변형: [[Heap-Snapshot]] · [[V8-Snapshot]]
|
||||
- 응용: [[Disaster-Recovery]]
|
||||
- Adjacent: [[Event-Sourcing]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: cold-start optim, leak diag, DR planning, time-travel debug strategy.
|
||||
**언제 X**: write-heavy hot path — snapshot overhead 의 measure 필요.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Snapshot as backup**: 매 same disk 의 snapshot 의 disk failure 의 protect X.
|
||||
- **No retention policy**: 매 snapshot accumulate → storage explode.
|
||||
- **Heap snapshot in prod under load**: 매 GC pause spike — staging 에서.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (V8 docs, Chrome DevTools docs, ZFS handbook, Postgres PITR docs).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — snapshot taxonomy, V8/heap/ZFS/PITR/CRIU patterns |
|
||||
Reference in New Issue
Block a user