https://github.com/borislavv/go-mmap
Comfortable implementation of mmap api in golang.
https://github.com/borislavv/go-mmap
efficiency golang mmap reading-files syscall
Last synced: about 1 month ago
JSON representation
Comfortable implementation of mmap api in golang.
- Host: GitHub
- URL: https://github.com/borislavv/go-mmap
- Owner: Borislavv
- License: unlicense
- Created: 2024-06-23T15:26:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-25T09:49:49.000Z (over 1 year ago)
- Last Synced: 2025-07-13T02:07:22.354Z (8 months ago)
- Topics: efficiency, golang, mmap, reading-files, syscall
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Reading via Mmap obviously uses syscall.Mmap to improve the efficiency of multi-threaded reading of a file in chunks.
## Mmap

## Pread

# How is it fast:
- ./main 0,01s user 0,01s system 96% cpu 0,012 total
- ./main 0,01s user 0,01s system 99% cpu 0,016 total
- ./main 0,01s user 0,01s system 98% cpu 0,021 total
Approximately it's working for 0,017ms.
# P.S.
But this method is ineffective if you have heavy work on the received data (that is, if you use data either from the end or from the beginning of the slice). This is due to the way the file is mapped into memory, thus making the processor cache less efficient.
In that case, I would recommend considering using syscall.Pread with offsets.