Interfaces for writing to files using mmap#237
Interfaces for writing to files using mmap#237pranav1344 wants to merge 2 commits intoMPLLang:mainfrom
Conversation
|
I've added writing to files using records as well as an example for writing in parallel to Running a primitive test on this write functionality using this code by generating 1GB arrays containing just a single letter gives this result:
|
…mmap and virtual memory changes to support the interfaces.
|
I'm not too sure if this part is too convoluted, but I wanted it to have parity with the read functionality, which supports reading from a certain offset. |
| val readChars: t -> int -> char ArraySlice.slice -> unit | ||
| val readWord8s: t -> int -> Word8.word ArraySlice.slice -> unit | ||
| val writeChar : {file: t, file_offset: int, array_slice_offset: int} -> char -> unit | ||
| val writeWord8s : {file: t, file_offset: int, array_slice_offset: int} -> Word8.word ArraySlice.slice -> unit |
There was a problem hiding this comment.
Here I find the two offsets confusing; I think it would be easier to just pass a single offset.
My understanding is that openFileWriteable s n gives us a file of n bytes. So, then, writeChar should be able to pass a single offset, somewhere in the range [0,n).
| fun openFileWriteable path final_size = | ||
| let | ||
| open Posix.FileSys | ||
| val file = createf (path, O_RDWR, O.append, S.flags [S.irusr, S.iwusr, S.irgrp, S.iroth]) |
There was a problem hiding this comment.
I'm curious, what happens here if the file already exists? Does createf behave like openf in that case?
| open Posix.FileSys | ||
| val file = createf (path, O_RDWR, O.append, S.flags [S.irusr, S.iwusr, S.irgrp, S.iroth]) | ||
| val fileSize = Position.toInt (ST.size (fstat file)) | ||
| val size = final_size + fileSize |
There was a problem hiding this comment.
Shouldn't this just be final_size ?
Add functionality to file.sig and file.sml to allow writes through mmap and mmunmap to replace PosixWriteFile.
(WIP and open to review)