9148c358d0
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 폴더 제거.
6.6 KiB
6.6 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-브라우저-메인-스레드-최적화-및-타임-슬라이싱 | 브라우저 메인 스레드 최적화 및 타임 슬라이싱 | 10_Wiki/Topics | verified | self |
|
none | A | 0.9 | applied |
|
2026-05-10 | pending |
|
브라우저 메인 스레드 최적화 및 타임 슬라이싱
매 한 줄
"매 long task 를 매 50ms 미만 chunk 로 split, scheduler.yield() 로 매 input 에 양보". 매 INP (Interaction to Next Paint, 2024 부터 Core Web Vital) 의 핵심 metric — 매 200ms 이하 가 Good. 매 2026 의 Scheduler API + isInputPending + Web Worker 의 매 standard toolkit.
매 핵심
매 Main thread 의 책임
- JS execution, Style + Layout + Paint, Compositing prep, Event dispatch.
- Long task: 50ms 초과 task — INP 의 적.
- Render-blocking: long task 동안 rAF, input handler 모두 starve.
매 Time slicing 전략
- Yield to event loop: scheduler.yield() (2026 baseline), 매 fallback 으로 setTimeout(0).
- Priority-aware scheduling: scheduler.postTask({priority: 'background'}).
- isInputPending(): input 의 pending 시 매 즉시 yield.
- Web Worker offload: pure compute (parsing, encoding, crypto) 는 main thread 떠남.
매 응용
- Large list rendering: virtualized + chunked.
- JSON parsing / encoding: Worker + Transferable.
- Hydration: priority-based React 19 / Astro / Qwik resumability.
💻 패턴
scheduler.yield() (2026 baseline)
async function processChunks(items: Item[]) {
for (const it of items) {
process(it);
if (navigator.scheduling?.isInputPending?.()) {
await scheduler.yield(); // resume after input is handled
}
}
}
scheduler.postTask with priority
// User-blocking: must run ASAP
scheduler.postTask(updateUserCriticalUI, { priority: 'user-blocking' });
// User-visible: default
scheduler.postTask(refreshSidebar, { priority: 'user-visible' });
// Background: prefetch, analytics flush
scheduler.postTask(prefetchNext, { priority: 'background' });
Manual time slicer (fallback)
async function timeSlice<T>(items: T[], work: (item: T) => void, budgetMs = 5) {
let start = performance.now();
for (const it of items) {
work(it);
if (performance.now() - start > budgetMs) {
await new Promise<void>((r) => setTimeout(r, 0));
start = performance.now();
}
}
}
Web Worker offload (Comlink pattern)
// worker.ts
import * as Comlink from 'comlink';
const api = {
parseLargeJSON: (text: string) => JSON.parse(text),
hashFile: async (buf: ArrayBuffer) => {
const h = await crypto.subtle.digest('SHA-256', buf);
return new Uint8Array(h);
},
};
Comlink.expose(api);
// main.ts
const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'module' });
const api = Comlink.wrap<typeof api>(worker);
const parsed = await api.parseLargeJSON(hugeText);
Transferable ArrayBuffer (zero-copy)
const buf = new ArrayBuffer(1024 * 1024 * 10);
worker.postMessage({ buf }, [buf]); // ownership transfers; main no longer holds
INP measurement (Performance Observer)
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries() as PerformanceEventTiming[]) {
const inp = entry.processingEnd - entry.startTime;
if (inp > 200) console.warn('Slow interaction', entry.name, inp);
}
});
observer.observe({ type: 'event', buffered: true, durationThreshold: 16 });
React 19 — useTransition for non-urgent updates
const [isPending, startTransition] = useTransition();
function handleSearch(q: string) {
setQuery(q); // urgent — input echo
startTransition(() => {
setSearchResults(filterHugeList(allItems, q)); // non-urgent — yields to input
});
}
IntersectionObserver — lazy heavy work
const io = new IntersectionObserver((entries) => {
for (const e of entries) {
if (e.isIntersecting) {
scheduler.postTask(() => mountHeavyComponent(e.target), { priority: 'background' });
io.unobserve(e.target);
}
}
}, { rootMargin: '200px' });
document.querySelectorAll('.lazy-section').forEach(el => io.observe(el));
Long Animation Frames (LoAF) API
new PerformanceObserver((list) => {
for (const e of list.getEntries() as any[]) {
console.warn('LoAF', e.duration, e.scripts);
}
}).observe({ type: 'long-animation-frame', buffered: true });
매 결정 기준
| 상황 | Approach |
|---|---|
| > 50ms synchronous work | Time slice with scheduler.yield() |
| Pure compute (parse, hash, image) | Web Worker + Transferable |
| Non-urgent state update (React) | useTransition |
| Off-screen heavy work | IntersectionObserver + postTask |
| Background prefetch | scheduler.postTask priority 'background' |
| Hot UI update with input | isInputPending checkpoint |
기본값: 매 task > 5ms 면 yield consider. 매 task > 50ms 면 split mandatory. 매 pure compute 는 Worker 의 first choice.
🔗 Graph
- 부모: Web-Performance · Core Web Vitals Optimization (INP, LCP, CLS) · INP-Optimization
- 변형: Scheduler API · Web Worker (웹 워커) · OffscreenCanvas
- 응용: 성능 중심의 웹 애니메이션 및 인터랙션 구현
- Adjacent: Long Tasks · Long-Animation-Frames · Comlink
🤖 LLM 활용
언제: time-slice boilerplate, Worker setup scaffold, scheduler API migration plan. 언제 X: 매 actual INP 측정 — RUM (CrUX, Web Vitals JS) 만 truth. LLM 의 perf claim 의 hallucination.
❌ 안티패턴
- Sync heavy work in input handler: 매 INP 폭증.
- setTimeout(0) busy-loop: scheduler.yield() preferred (priority-aware).
- Worker per task spawn: 매 startup overhead. Pool 또는 long-lived worker.
- structuredClone of huge data to Worker: Transferable 사용.
- Ignoring isInputPending: 매 yield 의 timing 의 너무 늦음.
🧪 검증 / 중복
- Verified (web.dev/inp 2026, Scheduler API spec, LoAF spec, Chrome DevTools Performance docs).
- 신뢰도 A.
🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — Scheduler API, time slicing, Worker offload, INP patterns |