Linux文件系统缓存文件是否有效? [英] Does the Linux filesystem cache files efficiently?
问题描述
然而,我在考虑Linux文件系统可能已经将文件缓存在内存中,因为它经常被访问。是对的吗?在你看来,memcache会提供一个真正的改进吗?或者它会做同样的事情,Linux已经在做什么?
我不是很熟悉Linux和memcache,所以我会很感激,如果有人可以澄清这一点。
是的,如果你每次打开它都不修改文件。 b
Linux将把文件的信息保存在内存中的copy-on-write页面上,并且将文件加载到内存中应该是非常快的(最坏的情况是页表交换)。
$ b
编辑:虽然,正如cdhowie指出的那样,没有linux文件系统。但是,我相信相关的代码是在linux的内存管理中,因此独立于所讨论的文件系统。如果您好奇的话,可以在linux源代码中阅读关于处理linux / mm / mmap.c中的vm_area_struct对象的信息。
I'm creating a web application running on a Linux server. The application is constantly accessing a 250K file - it loads it in memory, reads it and sends back some info to the user. Since this file is read all the time, my client is suggesting to use something like memcache to cache it to memory, presumably because it will make read operations faster.
However, I'm thinking that the Linux filesystem is probably already caching the file in memory since it's accessed frequently. Is that right? In your opinion, would memcache provide a real improvement? Or is it going to do the same thing that Linux is already doing?
I'm not really familiar with neither Linux nor memcache, so I would really appreciate if someone could clarify this.
Yes, if you do not modify the file each time you open it.
Linux will hold the file's information in copy-on-write pages in memory, and "loading" the file into memory should be very fast (page table swap at worst).
Edit: Though, as cdhowie points out, there is no 'linux filesystem'. However, I believe the relevant code is in linux's memory management, and is therefore independent of the filesystem in question. If you're curious, you can read in the linux source about handling vm_area_struct objects in linux/mm/mmap.c, mainly.
这篇关于Linux文件系统缓存文件是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!