Linux 文件系统自动由磁盘支持但完全托管在内存中?
我必须对一大堆文件进行大量的小型随机访问。 我有足够的主内存来保存所有数据。
当我将数据复制到临时 ramfs 文件系统并在那里进行处理时,这只需要等待磁盘访问所需时间的一小部分。
是否有一个 Linux 文件系统将所有数据保存在主内存中,将任何更改写入后备磁盘,但从不接触磁盘进行任何读取?
如果没有,是否可以调整 ext3 缓存以保证它们保存 100% 的数据和元数据?
I have to do lots of small random accesses to a whole bunch of files. I have more than enough main memory to hold all of the data.
When I copy the data over to a temporary ramfs filesystem and process it there, this takes only a small fraction of the time that waiting for disk access would take.
Is there a Linux file system which holds all of its data in main memory, writes any changes to a backing disk, but never touches the disk for any reads?
If not, can, say, ext3 caches be tuned so that they are guaranteed to hold 100% of data and metadata?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只是读取数据,那么您确实可以调整缓存,使所有数据都缓存在 RAM 中 - 有关详细信息,请参阅 /usr/src/linux/Documentation/sysctl/
fs.txtvm.txt您可以在此处进行调整。 当您写入数据时,就会出现问题,特别是当您使用 fsync() 或类似方法来确保数据已提交到实际磁盘时。由于操作系统必须在使用
fsync()
的情况下更新磁盘,因此如果您仍然想确保数据一致并且不会这样做,那么您无能为力不会因停电而迷路。您可能遇到的一个问题是
atime
或访问时间 - 默认情况下,每次访问文件时,inode 中的访问时间都会更新。 即使您认为自己只是在执行读取,这也会导致磁盘写入。 在您访问许多小文件的情况下,这可能是一个特殊问题。 如果您不关心跟踪访问时间,您可以使用noatime
挂载文件系统来禁用此“功能”。If you are only reading data, then you can indeed tune caching such that all data will be cached in RAM - see /usr/src/linux/Documentation/sysctl/
fs.txtvm.txt for details of what you can tweak here. The problem arises when you write data, particularly if you use fsync() or similar to ensure the data has been commited to the actual disk.As the OS has to update the disk in the case of a
fsync()
, there's not much you can do if you still want to ensure your data is consistant and wouldn't be lost in a power cut.One problem you might be running into is the
atime
or access time - by default every time a file is accessed the access time is updated in the inode. This will cause disk writes even when you think you are just performing reads. This can be a particular problem in your scenario where you are accessing many small files. If you don't care about tracking the access time you can mount your filesystem with thenoatime
to disable this 'feature'.为什么不尝试在 ramdisk 和物理磁盘之间创建 RAID 镜像呢?
但不确定它是否有效。 如果镜像必须始终同步,那么在写入时无论如何它都必须等待磁盘,但在读取时您应该有所收获。
但是,是的,对我来说,它看起来非常复杂,重新发明了方形 IO 缓存:)
不过,这将是一个很好的实验。
Why don't you try to create a RAID mirror between a ramdisk and a physical disk ?
Not sure if it's efficient though. If the mirror must always be synchronized, it will have to wait for the disk anyway when you write, but for reading you should gain something.
But yeah, to me it looks very much a complicated, wheel reinvented square IO caching :)
Would be a nice experiment, though.
看看这个:
http:// /freecode.com/articles/virtual-filesystem-building-a-linux-filesystem-from-an-ordinary-file
您可以将文件作为 FS 挂载到 RAMdisk 中,然后将其作为文件备份。
不确定您是否要频繁备份,但一次保存所有虚拟磁盘是一个很好的解决方案。
take a look at this :
http://freecode.com/articles/virtual-filesystem-building-a-linux-filesystem-from-an-ordinary-file
You can mount a file as a FS into a RAMdisk, then backup it as a file.
Don't sure you want to backup frequently, but it is a good solution to save all the virtual disk in only one time.