C**********n 发帖数: 100 | 1 mmap把磁盘上的一个文件映射到内存,据说这样对文件操作就可以加速了。
不过我不明白的是虽然mmap把文件从磁盘映射到内存,但程序实际上还是要从磁盘读文
件的把。为啥mmap这么一搞就快了呢? |
P*****f 发帖数: 2272 | 2 data from disk file directly goes to mmaped user-space area, no intermediate
kernel buffer needed
【在 C**********n 的大作中提到】 : mmap把磁盘上的一个文件映射到内存,据说这样对文件操作就可以加速了。 : 不过我不明白的是虽然mmap把文件从磁盘映射到内存,但程序实际上还是要从磁盘读文 : 件的把。为啥mmap这么一搞就快了呢?
|
w***g 发帖数: 5958 | 3 我觉得mmap并不一定总是能加速,要具体问题具体分析。我觉得大部分情况下即使能加
速,得到的那一点点提高也比不上FILE*和fstream的可移植性。
【在 C**********n 的大作中提到】 : mmap把磁盘上的一个文件映射到内存,据说这样对文件操作就可以加速了。 : 不过我不明白的是虽然mmap把文件从磁盘映射到内存,但程序实际上还是要从磁盘读文 : 件的把。为啥mmap这么一搞就快了呢?
|
t****t 发帖数: 6806 | 4 mmap is already in POSIX, so it's quite portable. but you are right since it
's not much faster -- how fast can it be...
【在 w***g 的大作中提到】 : 我觉得mmap并不一定总是能加速,要具体问题具体分析。我觉得大部分情况下即使能加 : 速,得到的那一点点提高也比不上FILE*和fstream的可移植性。
|
w***g 发帖数: 5958 | 5 Windows下没有。用标准C和C++库编出来的程序在windows下也能用的。
it
【在 t****t 的大作中提到】 : mmap is already in POSIX, so it's quite portable. but you are right since it : 's not much faster -- how fast can it be...
|
c****e 发帖数: 1453 | 6 It's could handle very high throughput, especially for data burst. Since
after you write to memory, your are done, the kernel takes care of the rest.
E.g, my program can write a few G bytes in a few seconds. |