In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to realize zero-copy technology in Linux. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. Regular file reading and writing [file-kernel space-user space]
two。 Use mmap so that data transfer does not need to go through user space
It is mainly the one-to-one correspondence between the location of files on the hard disk and an area of the same size in the logical address space [user state space]. After the implementation of such a mapping relationship, the process can directly read and write this section of memory in the way of pointer, and the system will automatically write back dirty pages to the corresponding file disk, that is, the operation of the file is completed without having to call system call functions such as read,write.
3. Using sendfile to further reduce the direct data copy of the kernel
So far, we have reduced the number of data copies, but there is still one copy, which is the copy of the page cached to the socket cache. Then can you omit this copy, too?
With the help of hardware [support for scatter-gather features], we can do it. Previously, we copied the data from the page cache into the socket cache, but in fact, we just need to pass the buffer descriptor to the socket buffer and then pass the data length, so that the DMA controller can package and send the data in the page cache directly to the network.
To sum up, the sendfile system call uses the DMA engine to copy the contents of the file to the kernel buffer, and then adds the buffer descriptor with file location and length information to the socket buffer. This step does not copy the data from the kernel into the socket buffer. The DMA engine copies the data from the kernel buffer to the protocol engine to avoid the last copy.
After reading the above, have you mastered how to implement zero-copy technology in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.