简体   繁体   English

数据的mmap和页面对齐-这会提高性能吗?

[英]mmap and page alignment of data - does this increase performance?

Is there any benefit to aligning my data in an mmap()ed file? 在mmap()文件中对齐我的数据有什么好处? ie if data for an object to be read is offset with a multiple of the OS'es page size from the start of the file (or mmap?). 也就是说,如果要读取的对象的数据从文件的开头(或mmap?)偏移了操作系统页面大小的倍数。

Would this result in faster read performance because less page faults are generated and the OS doesn't have to swap data in and out. 这会导致更快的读取性能,因为生成的页面错误更少,并且操作系统不必交换数据进出。 How does this work? 这是如何运作的?

From reading around I have the answer. 通过阅读,我得到了答案。

If a small piece of data will cross the boundary of a page, it's probably better to align it with the next page as the OS loads data from the disk pages at a time. 如果一小部分数据会越过页面的边界,则最好将其与下一页对齐,因为操作系统会一次从磁盘页面加载数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM