Difference between writefileex and writefile

Source: Internet
Author: User

The following is a discussion from a group of friends that needs to be organized:

Writefileex and writefile have different access speeds in batch to reflect the advantages of writefileex.

The benefit of using ovlp is that you do not need to move the file pointer.
It is convenient to access it immediately. Because it is not cached in the system cache, it is necessary to hurry up.
But not absolute
Because you do not cache access by yourself
This can reduce disk efficiency.
Overall Speed will decrease

Because the file_flag_no_buffering flag is used
This may increase the number of disk seek operations.
The system cache optimizes the head to reduce the time required to read and write a large number of files.
The file_flag_no_buffering flag is required.
Although it may slow down, it increases the IO delivery efficiency.
The reduced speed can be restored after optimization in other stages

Reduces disk wait time

The interval between two accesses is significantly reduced.
That is, the number of visits increases significantly within the unit time.
Reducing disk speed is caused by disk seek
If the disk head moves more frequently due to a large number of requests

Is location offset processing performed for disk seek? This is basically the case for high-performance disk access.
Cannot leave this
However, optimization is also required on the disk.
Synchronous read/write will make the disk wait for a long time
Asynchronous access makes it difficult to move file pointers Based on ovlp to overcome the above two problems
It is suitable for concurrency. for large-scale access, "synchronous read/write will keep the disk waiting for a long time" is because the time is wasted on the cache allocated by the system, right? Not just this
Because it takes time for you to deliver a request,

Only when one request is complete can another asynchronous request be accepted. The request can be completed first.

No ovlp

You must set the file pointer for each read/write operation.
In this way, the correct position can be reached,

This is not conducive to concurrent access, access is more troublesome every time delivery, everything is ready for the disk, you only need to directly operate on OK
Therefore, the efficiency is the highest.
On the disk Io queue
All requests are queued in advance.

Therefore, you can perform multiple operations without waiting.

In the driver, ovlp corresponds to offset and iostatsblock.
In addition, the actual parameter of event ovlp is completed. For file access, it is the file offset.
You can see the ovlp structure.

Writefileex allows you to implement the thread pool by yourself
Writefile implementation requires low efficiency

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.