Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jorropo/mmu-ring
https://github.com/jorropo/mmu-ring
Last synced: 18 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jorropo/mmu-ring
- Owner: Jorropo
- License: mit
- Created: 2024-10-14T16:31:39.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-10-14T19:12:18.000Z (2 months ago)
- Last Synced: 2024-12-02T16:46:26.766Z (21 days ago)
- Language: Go
- Size: 7.81 KB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MMU-ring
MMU-ring is a copy-free hardware ring buffer implementation.
It never copies data around, yet it always provide single contiguous buffers for both content and unused space.
This is achieved by using the CPU's MMU to map the same physical memory twice head to tail.
This means, in virtual memory we allocate a buffer twice as big, however the second half points to the same physical memory as the first half.
Then if the ring would wrap around, rather than having to handle this into two steps or return two buffers we can overflow from the first mapping into the second mirror mapping.The buffers are valid for any operation, can be passed to the OS like with os.File.Read.
Creating and destroying an MMU buffer require doing a couple of syscalls, altho no IO and is slightly costier than a heap allocation. There is no ongoing CPU cost once it has been created.
You need to call `.Close` when you are done using the buffers, the special mappings are not collected by GC.
This is incompatible with linux no MMU (altho go does not support linux no MMU anyway so not sure how you would manage to run anyway).
# TODO:
- Windows support, they have APIs designed to do very exactly this.
- MacOS Support, idk.
- Generic posix support, shm ¿ altho that not anonymous.
- Copy-free Resizing (remap)