Efficiency Comparison Between MMAP image and direct Io

Source: Internet
Author: User
You can't simply say which method is highly efficient. Either method is nothing more than the OS that helps you cache your memory, and then the fl at some point in time. To the memory. MMAP can easily simplify file operations and is more efficient than Directly Reading and Writing files.


Introduced a few paragraphs: "This problem is complicated and it cannot be simply said that MMAP is faster than block buffer.

The main difference between them is that the system manages the buffer when using MMAP.

If the user manages the buffer, when the buffer you use is too large and the system memory is insufficient, it will cause elimination.

The performance of the server is greatly reduced. If the buffer used is too small, it does not reflect the advantages of using the buffer. Therefore

Users can find the appropriate amount of buffer.

Another advantage of using MMAP is to avoid unnecessary copies and facilitate programming. Consider the following example:

All content in the file is reversed (that is, ABCD is changed to dcba), and the buffer and MMAP methods are used for comparison. Yes

For more information, see <windows core programming>. "

"This method is not faster than bypassing the buffer for direct DMA. When reading and writing large files and reading large parts continuously

Direct Io is faster. "

"And using MMAP will make a big change in the solution, and the entire system may be simpler and clearer. D

Ma is faster, but cannot be transplanted. Therefore, MMAP is faster than read/write. "

"Comparison of access to files by MMAP and read/write routes

Whether using MMAP or read/write to access files, the file must go through two caches in the kernel: one is using

Page-based Cache organized by ddress_space; one is cache organized by buffer, but in fact the two

Caches are only organized in different ways in the same buffer pool. When you need to read and write content from a file

The function provided in ress_space_operation is that the path is consistent.

If the read/write mode is used, you must specify the number of reads to the kernel and then buffer the obtained content from the kernel.

The pool is copied to the user space. The write process is similar. MMAP has the advantage

The content is mapped to the user space, and the user can directly read and write this content to the kernel buffer pool.

It is usually faster to copy back and forth between the core and the user space. However, the MMAP method is only applicable to updating, reading, and writing a fixed size

The file area does not support such operations as constantly writing content into the file to export to file growth.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.