Hello, thanks for replying
https://en.wikipedia.org/wiki/Page_cache reads:
In computing, a page cache, sometimes also called disk cache,[2] is a transparent cache for the pages originating from a secondary storage device such as a hard disk drive (HDD). The operating system keeps a page cache in otherwise unused portions of the main memory (RAM), resulting in quicker access to the contents of cached pages and overall performance improvements. A page cache is implemented in kernels with the paging memory management, and is mostly transparent to applications.
But I guess you're referring to read-caching, right?
correct
BTW: Filesystems are on the same layer as the page cache but separate entities:
https://upload.wikimedia.org/wikipedia/ ... kernel.svg - so which standard FS do implement read caching as an "own" feature (apart from ZFS)?
I know there's CONFIG_FSCACHE from the kernel .config but haven't seen it activated by default or by hand so far.
The description of "CONFIG_BCACHE" is
Allows a block device to be used as cache for other devices; uses a btree for indexing and the layout is optimized for SSDs.
As I understand that's another cup of tea and maybe not what you ment?!
Next I don't expect huge files to be cached in large chunks. Megabytes maybe but gigabytes, probably not. Instead you can expect caching in small portions, usually 4-KB pages.
Are you sure? Here's what I see:
Code: Select all
#> free -h | grep -Ei 'buff/cache|mem'
total used free shared buff/cache available
Mem: 62G 2.5G 49G 337M 10G 59G
#> tar --create --file /mnt/rdisk/test.tar /usr/src
tar: Removing leading `/' from member names
#> free -h | grep -Ei 'buff/cache|mem'
total used free shared buff/cache available
Mem: 62G 2.4G 44G 2.4G 15G 57G
The cache grew approximately 5GB.
For me it's not so important how large the chunks in memory are but to prevent a huge file drive away all the cache-worthy files from the cache.
And even then the filesystem cache is cleared by the kernel at given checkpoints, (correct me if I'm wrong) depending on the I/O scheduler, which you've selected in your kernel configuration, and the mount options you've selected.
Checkpoints? Clear the read cache in intervals? What would be the sense in that? AFAIK the cache holds data until it's overwritten or the box is powered down (or you instruct the kernel to drop caches like 'echo 3 > /proc/sys/vm/drop_caches'). There are kind of checkpoints etc. but I think that refers to a write cache which is implemented by the file systems.
I'd like to ask: what makes you believe the page cache is involved at all and why do you believe that is a problem?
The page cache is involved because as what I read this far does support that.
Code: Select all
$> man free
[…]
buffers
Memory used by kernel buffers (Buffers in /proc/meminfo)
cache
Memory used by the page cache and slabs (Cached and Slab in /proc/meminfo)
As above written I do not want to make big files like archives or videos kick data - that is requested often - out of the page cache. So ideally I could tell the kernel to not cache such files. vmtouch can set an upper size limit regarding cached files:
Code: Select all
vmtouch [OPTIONS] ... FILES OR DIRECTORIES ...
[...]
-m <max file size>
Maximum file size to map into virtual memory. Files that are larger than this will be skipped. Examples: 4096, 4k, 100M, 1.5G. The default is 500M.
However, this only refers to files that are given at execution time so all new files will be ignored. As well files can grow beyond that size after execution of vmtouch. Okay, a cron script may help here, still if it runs every 10 minutes there is plenty of time to fill the cache with undesired data.
There is a demon mode for vmtouch but it only refers to
locking files in the page cache, not to prevent storing them.
I doubt that I can educate much here.
Since there is only your reply in a long time I guess there is not much I can do about this "issue". I am planning a new system and I want to make it fast. So reading data from ram is magnitudes faster than reading these from HDD or SSD.
I might be wrong about some things I wrote.