x/exp/mmap: should offer access to the mapped byte slice #20642
Labels
FeatureRequest
Issues asking for a new feature that does not need a proposal.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Currently the only way the mapped data is accessible is through the
ReadAt(p []byte, off int64)
method, which copies fromr.data
(the mapped area) top
.I realize that this was probably a deliberate decision, because if it were possible to create further references to the underlying (mapped) array of
r.data
and those references were accessed after the ReaderAt'sClose()
method was called, the application would crash.However, one of the reasons to use mmap is usually performance. In my application I am just copying big chunks of data out of an mmapped area into a pipe. To be honest I have not quantified the impact, but I can imagine that if I could avoid the second copying I could increase the throughput/reduce the CPU load.
Maybe the issue of unsafeness can be addressed by allowing access through a Method named something like
UnsafeRawAccess()
or something?The reason why I don't just implement the whole mmapping myself is that the package still offers some value in abstracting the mmap system calls for the different platforms.
The text was updated successfully, but these errors were encountered: