3 ms·
random reads are ok. writes through a mmap are a disaster.
by perbu 1y ago
random reads are ok. writes through a mmap are a disaster.
- vlowther 1y agoOnly if you are doing in-place updates. If append-only datastores are your jam, writes via mmap are Just Fine: $ go test -v === RUN TestChunkOps chunk_test.go:26: Checking basic persistence and Store expansion. chunk_test.go:74: Checking close and reopen read-only chunk_test.go:106: Checking that readonly blocks write ops chunk_test.go:116: Checking Clear chunk_test.go:175: Checking interrupted write --- PASS: TestChunkOps (0.06s) === RUN TestEncWriteSpeed chunk_test.go:246: Wrote 1443 MB/s chunk_test.go:264: Read 5525.418751 MB/s --- PASS: TestEncWriteSpeed (1.42s) === RUN TestPlaintextWriteSpeed chunk_test.go:301: Wrote 1693 MB/s chunk_test.go:319: Read 10528.744206 MB/s --- PASS: TestPlaintextWriteSpeed (1.36s) PASS
- karel-3d 1y agoInteresting. We use it to mmap a big file that just-enough fits in memory and we mostly read randomly (around 1/1000 of the file) and sometimes sparringly write and it works great. I haven't tested how would it work more fast with Seek/Read/Write, but mmap is very ergonomic for this; it just acts as a slice and it's basically invisible; and you can then take the slice of bytes and unsafe.cast it as slice of something else. Very easy.