特定のプログラムのRAMメモリキャッシュを無効にする

特定のプログラムのRAMメモリキャッシュを無効にする

C で作成されたバイナリを使用していくつかのベンチマーク テストを実行しています。カーネルにこれらのバイナリ プログラムのどの部分もキャッシュしないように指示する方法はありますか?

答え1

「drop_caches」に関するカーネルドキュメントを参照してください。

https://www.kernel.org/doc/Documentation/sysctl/vm.txt

ここに小さなセクションがあります:-

Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes.  Once dropped, their
memory becomes free.

To free pagecache:
    echo 1 > /proc/sys/vm/drop_caches
To free reclaimable slab objects (includes dentries and inodes):
    echo 2 > /proc/sys/vm/drop_caches
To free slab objects and pagecache:
    echo 3 > /proc/sys/vm/drop_caches

This is a non-destructive operation and will not free any dirty objects.
To increase the number of objects freed by this operation, the user may run
`sync' prior to writing to /proc/sys/vm/drop_caches.  This will minimize the
number of dirty objects on the system and create more candidates to be
dropped.

関連情報