LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Keeping a file in RAM (https://www.linuxquestions.org/questions/linux-server-73/keeping-a-file-in-ram-591356/)

Leolo 10-12-2007 01:53 PM

Keeping a file in RAM
 
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.

ilikejam 10-12-2007 02:59 PM

Hi.

Try setting the swappiness value to 0:

echo 0 > /proc/sys/vm/swappiness

Might help. I don't know of a way of telling the kernel to keep specific files in RAM, though.

Dave


All times are GMT -5. The time now is 10:58 AM.