To Drop or Not To Drop: Identifying Unused File Cache in Linux

image

Context

Driven by technological advances, the DRAM spot price continues to decrease. The memory capacities have expanded far beyond what was imaginable decades ago. As a result, the average memory utilization in consumer devices and data centers rarely exceeds 60 percent. Due to leakage currents, DRAM cells require actively expending energy on periodic refresh to retain their data. In contemporary systems, this refresh process occurs uniformly across all memory, regardless of the actual usage. This raises the question: can unused memory be disabled (offlined) to reduce energy consumption?

On the hardware side, the power-management features of existing SDRAM specifications apply only to coarse granularities of over 1 GiB. On the software side, OS memory management remains largely incapable of leveraging these features due to outdated assumptions about memory. The OS operates with the assumption that "unused memory is wasted memory" and aggressively fills all memory with file cache to maximize performance. Paging abstracts away physical fragmentation, leading page-frame allocators to scatter allocated page frames across the physical address space. Consequently, in a system with significant uptime, finding contiguous unused memory segments for offlining becomes nearly impossible.

To improve the OS memory management and integrate the power-management aspect into it, we have developed a compaction mechanism optimized for coarse granularities. The mechanism divides the physical address space into slices, each representing a power-management domain, and periodically reorganizes memory contents to reduce the amount of active slices. Each slice is assigned a score based on the estimated effort to offline it. By prioritizing the slices with the lowest score, the mechanism achieves near-optimal compaction with minimal effort. Additionally, it also addresses the problem of ever-growing file cache by freeing its pages instead of migrating where possible.

Problem

The current file-cache freeing approach is to free every unmapped page that is encountered during compaction. However, this strategy of indiscriminate freeing has proven to be suboptimal. If recently freed data is needed again soon, it must be reloaded from disk, causing a hidden performance penalty.

Goal

The current Linux kernel lacks mechanisms to predict which pages will be accessed again. The classical approach to prediction used to implement all sorts of caches is examining the past and extrapolating it into the future. While the page-frame reclamation algorithm seems to fulfill the exact purpose, it is designed to first become active under memory pressure. Its accounting is not up-to-date unless memory is running low and it tends to classify unmapped pages as inactive. To address this, a mechanism to keep statistics and use it to estimate the likelihood of future access to file-cache pages must be developed within this thesis.

As the cache pages in question are unmapped, the only way they have been accessed in the recent past is via the regular system calls: open, read, write, and close. If they became unmapped recently, this change happened via either munmap or exit system calls. All these system calls transfer the control flow to the kernel and could be used to efficiently implement tracking of regularly used pages.

Topics: Linux, Energy, Physical Memory Management, Page Cache


DIMES Workshop Best Paper Award
The New Costs of Physical Memory Fragmentation
Alexander Halbuer, Illia Ostapyshyn, Lukas Steiner, Lars Wrenger, Matthias Jung, Christian Dietrich, Daniel LohmannProceedings of the 2nd Workshop on Disruptive Memory Systems (SOSP-DIMES '24)Association for Computing Machinery2024Best Paper Award.
PDF Details 10.1145/3698783.3699378 [BibTex]

Previous Work

Enhancing Energy Efficiency with Advanced DRAM Management in Linux

Modern computer systems face a significant challenge in managing physical memory efficiently, especially in the context of energy consumption. Specifically, the DRAM (Dynamic Random-Access Memory) components in these systems consume a considerable amount of energy due to their constant refresh requirements. [PDF]

 
Typ
Masterarbeit

 
Status
abgeschlossen

 
Supervisors
Alexander Halbuer
Christian Dietrich
Daniel Lohmann

 
Projects
ParPerOS
DRAMaOS

 
Bearbeiter
Illia Ostapyshyn (abgegeben: 01. Nov 2024)

System-Independent Cost Model Derivation for Energy-Aware Compaction

Effective memory compaction and reclamation with the goal of saving energy requires precise prediction about its costs and benefits. In this thesis, statistical methods shall be evaluated to automatically derive a cost model for energy-aware compaction.

 
Typ
Bachelorarbeit

 
Status
abgeschlossen

 
Supervisors
Illia Ostapyshyn
Daniel Lohmann

 
Project
DRAMaOS

 
Bearbeiter
Anastasiia Martynkova (abgegeben: 14. Jul 2025)