#Architecture

باطل‌سازی کش در سیستم‌های کم‌حافظه

۱۲ آبان ۱۴۰۳ • ۸ دقیقه

روی میکروکنترلری با حافظه کم، خودِ ساختار کش هم باید ارزان باشد. LRU با یک فهرست پیوندی دقیق است، اما اشاره‌گرها بخش بزرگی از همان ۲۵۶ کیلوبایت را می‌خورند.

ARC دو فهرست برای صفحات تازه‌دیده و صفحاتی که دوباره استفاده شده‌اند نگه می‌دارد و اندازه آن‌ها را با بار کاری جابه‌جا می‌کند. این تطبیق برای الگوی دسترسی مخلوط بهتر از LRU ثابت است، به شرطی که فراداده هر ورودی کوچک بماند.

در آزمایش روی ردپای دسترسی واقعی، ARC نرخ برخورد را چند درصد بالا برد، ولی فقط وقتی ورودی‌ها از یک بافر ثابت آمده بودند. تخصیص پویا وسط مسیر داغ، سود کش را با تکه‌تکه شدن حافظه پاک می‌کرد.

#Architecture

Evaluating Cache Invalidation in Memory-Constrained Systems

Nov 2, 2024 • 8 min read

On a small microcontroller the cache index has to be cheap. A pointer-heavy LRU list is accurate, but the pointers themselves consume a visible share of a 256KB SRAM budget.

ARC keeps one list for pages seen once and another for pages reused, then moves capacity between them as the workload shifts. That adapts better than a fixed LRU policy when scans and hot keys are mixed, as long as each entry stays compact.

On a captured access trace, ARC raised the hit rate by a few points only when entries came from a fixed buffer. Dynamic allocation on the hot path spent the gain on heap fragmentation.