Add mmap-io-backed append-only file, mmap-backed Index, and mmap-backed Partition with direct mapped-buffer reads#315
Add mmap-io-backed append-only file, mmap-backed Index, and mmap-backed Partition with direct mapped-buffer reads#315Copilot wants to merge 23 commits into
Conversation
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/463b57a0-9374-4236-8178-d094a7d9bc95 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/463b57a0-9374-4236-8178-d094a7d9bc95 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
|
@copilot You forgot the "mmap" part of the thing. Use mmap-io (@riaskov/mmap-io version) to implement actual OS based memory mapping of a file, with the same instructions I gave earlier |
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/18ebd1ff-e382-4dfa-9a50-a60060a9c0a8 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Implemented with real OS-backed file mapping via |
…bclass, use mmap.PAGESIZE, remove dirty tracking Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/46c4e985-12a9-4c87-9e08-8b7c62fa7e27 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/46c4e985-12a9-4c87-9e08-8b7c62fa7e27 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
All review comments addressed in commits
|
|
@copilot add an example implementation of an append only mmap file backed Index and place it besides the existing Index implementation. |
…bleIndex, MmapWritableIndex, MmapReadOnlyIndex) Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/2d421c70-53fb-4e29-a82f-e3da3bb18748 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
…slint-disable comment Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/2d421c70-53fb-4e29-a82f-e3da3bb18748 Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Added in commit
|
albe
left a comment
There was a problem hiding this comment.
@copilot apply the comment change, then run the index benchmark with the mmap'd index implementation against stable and latest basic version. If mmap is slower for the read benchmark, implement a caching of the read Entry items that fills up and returns a slice of the cached array
|
|
||
| const buf = Buffer.allocUnsafe(this.EntryClass.size); | ||
| entry.toBuffer(buf, 0); | ||
| this.file.write(buf); |
There was a problem hiding this comment.
Add a file API that allows entry.toBuffer() to receive the buffer location of current write position of the file, with a given length (or until the end of the mapped range by default). e.g. entry.toBuffer(this.file.write(this.EntryClass.size), 0)
There was a problem hiding this comment.
Done in commit f9516f6. Added a dedicated reserve(size) method to WritableAppendOnlyMmapedFile that reserves bytes at the current write position and returns the mapped subarray for in-place serialisation. MmapWritableIndex.add() now uses entry.toBuffer(this.file.reserve(this.EntryClass.size), 0) — no intermediate Buffer.allocUnsafe per add. The original write(data) keeps its Buffer/string signature unchanged.
…ush=false, remove redundant mmap.sync Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/0e91957c-d8cf-43b2-b439-215ce3b593cd Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/0e91957c-d8cf-43b2-b439-215ce3b593cd Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/9333e5a7-ad3f-4843-a679-ef6f910cef2c Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/9333e5a7-ad3f-4843-a679-ef6f910cef2c Co-authored-by: albe <4259532+albe@users.noreply.github.com>
|
Bench result with 1000 Writes being consumed across N readers. 1 OP = 1000 reads
|
| } | ||
|
|
||
| this.file.open(); | ||
| this.fd = this.file.fd; |
There was a problem hiding this comment.
Where is the copied reference to fd needed? Only file should hold it
Agent-Logs-Url: https://github.com/albe/node-event-storage/sessions/ff8309e4-215b-45a8-b61a-5bb124c4f30b Co-authored-by: albe <4259532+albe@users.noreply.github.com>
Implemented in Reran the storage benchmark (
|
Uh oh!
There was an error while loading. Please reload this page.