Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FRex/rampin
Try to make Windows preload files into RAM by memory mapping and touching them.
https://github.com/FRex/rampin
Last synced: 28 days ago
JSON representation
Try to make Windows preload files into RAM by memory mapping and touching them.
- Host: GitHub
- URL: https://github.com/FRex/rampin
- Owner: FRex
- License: unlicense
- Created: 2019-05-31T04:43:33.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-02-20T15:23:14.000Z (almost 4 years ago)
- Last Synced: 2024-08-04T02:09:22.264Z (4 months ago)
- Language: C
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - rampin
README
# rampin
A small C program to try keep a file or few in Windows RAM cache. For a Unix
(not only Linux) alternative see [vmtouch](https://linux.die.net/man/8/vmtouch).Takes one or more filenames as arguments, opens them as read only and memory
maps them whole, then accesses each 4 KiB page of it to bring them into memory
and then sleeps for 30 seconds and accesses them again to keep them in memory.**By default it never quits so you'll have to somehow kill it once you are done.**
A sole `-h` will print full help to stdout. Options `-0`, `-1`, etc. up to `-9` will
make it quit after that many sleep + touch loops, not counting the initial one
so `-0` will map the file, touch all pages once, and quit right after, `-1`
will map, touch once, and sleep once and touch again and then quit, etc.This program only makes sense if you have RAM to spare and/or are on 64-bit. I
wrote it to speed up level loading in an old game that has a total of 5 GiB of
assets and a 32-bit exe, so the game, OS and all the assets fit into my PC's RAM.**This program might easily backfire if used too greedily and your OS might start paging to disk!**
To make it easier to rampin entire dir tree I use this help script named `rampintree`,
but mapping and touching many files one after another has been added recently to the
`rampin` program itself so just `rampin *` or `rampin` + list of files works too.
You can write a similar script in Powershell, Batch, pure sh and Busybox, etc.In the future `rampin` will likely offer an option to recurse directories on its
own (if you need that option now you can open an issue here to let me know).```
#!/bin/bashif [ "$#" -eq 1 ]
then
find "$1" -type f | xargs -P 99000 -I @ rampin @
fi
```The above might work poorly and cause lower reading speeds on an HDD. For an
HDD a script that reads files one by one (and uses only one process) could be:
```
#!/bin/bash
if [ "$#" -eq 1 ]
then
rampin `find "$1" -type f`
fi
```Go to releases to download a Windows exe compiled with Pelles C with no `-O2`
to avoid running into any `-O2` optimizer bug similar to this one that affected
`stb_image`: [Pelles C forum bug report](https://forum.pellesc.de/index.php?topic=7837.0)