Greetings,
I have a large MySQL table, over 8GB. The server it is on has 24 GB of RAM, however. I was hoping to keep the table in RAM, for a huge speed win.
RAM disks won't work. Copying the files into RAM at each boot would take too long. And then one would have to figure out how to sync the copy in RAM with the copy on the disk.
So I have a script that runs from rc.local at boot :
su --command="batch -f /home/dw/prive/user-daemon/pre-load" mysql
/home/dw/prive/user-daemon/pre-load is
#!/bin/sh
DB=dw
DEST=/dev/null
LOG=/home/dw/prive/log/pre-load.log
date >>$LOG
/usr/bin/time -p -a -o $LOG bash -c \
"for n in ~mysql/$DB/*.M* ; do echo \$n >>$LOG ; cat \$n >$DEST 2>>$LOG ;done"
This works... for about a day. Cache usage goes up to ~10GB. However, by next morning I notice that cache goes back down to ~5GB.
I suspect that the backup cron job at 2 AM is convincing the kernel to free some cache.
Short of running pre-load each day, is it possible to convince the kernel to keep a set of files in cache? Some mmap magic?
Any pointers appreciated.
Thank you.