如何在我的linux系统中停止磁盘I / O的页面缓存? [英] How to stop page cache for disk I/O in my linux system?

查看:157
本文介绍了如何在我的linux系统中停止磁盘I / O的页面缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的基于Linux2.6.32.12的系统:

1它包含20个进程,占用了很多usr cpu
2它需要写磁盘速率为100M / s的数据,最近不会使用这些数据。

Here is my system based on Linux2.6.32.12:
1 It contains 20 processes which occupy a lot of usr cpu 2 It needs to write data on rate 100M/s to disk and those data would not be used recently.

我的期望:

它可以稳定运行,磁盘I / O不会影响我的系统。

What I expect:
It can run steadily and disk I/O would not affect my system.

我的问题:

一开始,系统像我想的那样运行。但随着时间的推移,Linux会为磁盘I / O缓存大量数据,从而导致物理内存减少。最后,没有足够的内存,那么Linux将交换进出我的进程。这将导致I / O问题,即I / O使用了大量的cpu时间。

My problem:
At the beginning, the system run as I thought. But as the time passed, Linux would cache a lot data for the disk I/O, that lead to physical memory reducing. At last, there will be not enough memory, then Linux will swap in/out my processes. It will cause I/O problem that a lot cpu time was used to I/O.

我尝试了什么:

我尝试通过每次写一个大块时使用fsync来解决问题。但是当缓存增加时,物理内存仍然在减少。

What I have try:
I try to solved the problem, by "fsync" everytime I write a large block.But the physical memory is still decreasing while cached increasing.

如何在这里停止页面缓存,对我来说没用;

更多信息:

当Top show免费46963m,一切都很好,包括cpu%wa低和vmstat显示没有si左右。

当Top显示免费273m时,%wa是如此之高以至于影响我的进程而vmstat显示了很多si等等。

More infomation:
When Top show free 46963m, all is well including cpu %wa is low and vmstat shows no si or so.
When Top show free 273m, %wa is so high which affect my processes and vmstat shows a lot si and so.

推荐答案

我不确定改变某些事情会影响整体表现。

I'm not sure that changing something will affect overall performance.

也许你可以使用 posix_fadvise(2) sync_file_range(2)(更少见 fsync(2) fdatasync(2) sync(2) syncfs(2),.. )。另请参阅 madvise(2) mlock(2) munlock(2),当然还有 mmap(2) munmap(2)。也许 ionice(1)可能有所帮助。

Maybe you might use posix_fadvise(2) and sync_file_range(2) in your program (and more rarely fsync(2) or fdatasync(2) or sync(2) or syncfs(2), ...). Also look at madvise(2), mlock(2) and munlock(2), and of course mmap(2) and munmap(2). Perhaps ionice(1) could help.

在读者过程中,您可能使用 readhahead(2)(可能在一个单独的主题中)。

In the reader process, you might perhaps use readhahead(2) (perhaps in a separate thread).

升级内核(达到3.6或更高) 当然可以提供帮助:自2.6.32以来,Linux已经在这些点上有了显着改善,这是非常古老的。

Upgrading your kernel (to a 3.6 or better) could certainly help: Linux has improved significantly on these points since 2.6.32 which is really old.

这篇关于如何在我的linux系统中停止磁盘I / O的页面缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆