Closed Dr-Emann closed 5 years ago
Mhh, yeah ... if there is no other way, like somehow keeping the memory map alive instead of repeated mapping and unmapping, that might be best.
Meanwhile the currently released positioned-io 0.2 still essentially uses seek_read.
I don't think so, at least not implemented directly on File
. It could be done as a wrapper around file which also implements ReadAt
, but doesn't move the file pointer.
I added a wrapper that simply uses seek_read
(RandomAccessFile
) and released it as positioned-io-preview = "0.3.1"
. It implements ReadAt
but not Read
.
It is possible to observe the moving cursor by constructing another File
handle with the same file descriptor, but at least the wrapper makes you think twice.
The implementation of ReadAt for windows is very slow. Benchmarks are here, and a violin graph from a run is attached:
The memory map based implementation currently used is about an order of magnitude slower than using a refcell. Even faster is to use
seek_read
(which does change the current offset in the file.I personally would use the
seek_read
function, and document that uses ofReadAt
may or may not change the current file offset.