How to run BOINC from RAM, dramatically reducing the access time of projects to databases, while maintaining persistence [Linux Only]

in #gridcoin6 years ago

EDIT: To follow this tutorial it is necessary to have rsync and curl installed, 95% of linux systems will already have it installed. Just make sure they are.

Let's begin this post saying that this is not suited for computers with SDDs, since the difference it's probably minimal and for computers with less than 4GiB of ram. It is also not suited for projects with no large databases such as Universe@home or NFS@home.

Now let's explain what we are gonna do. A lot of projects bring with themselves large files with important data, as it can be seen in the projects folder. work-units need to access to do their work. Depending on the work-unit, and your harddrive, it can be a significant bottleneck . Linux has the ability to easily and transparently allow to store files in RAM, using something called tmpfs. Because we wish for our work to not be temporary, but permanent, we will use a script that periodically stores the changes on the HDD .

Let's start. . All the following opperations require root so be sure to be in root mode. I also adapted the commands so if there are differences between distributions you can use them in copypaste anyway. Cause i'm nice. But it will output some errs that you can harmlessly ignore.

You most likely have boinc set-up to auto start with systemd . And the service it's named either boinc or boinc-client. We must disable it with

systemctl disable boinc & systemctl disable boinc-client

We will start working on systemctl units now so it's better to switch to the systemd directory.

cd /usr/lib/systemd/system

Now, to work on the Boinc service

mv boinc* boinc-ram.service

And now we need to edit it. I recommend nano but you may use any file editor you want .

nano boinc-ram.service

It should be looking like this :

https://pastebin.com/svj4ipYv

And we must edit it so it looks like this :

https://pastebin.com/1UXN34MU

Now, with the boinc settings settled, we must move on to our persistence manager.

First we create the directory

mkdir /var/lib/boinc/ram

now we define it in fstab, so it is mounted at boot.

echo "tmpfs /var/lib/boinc/ram tmpfs nodev,nosuid 0 0" >> /etc/fstab

Now. We need a script that moves files in and files our. We will call it boinc-prst.sh

You can check it out here : https://pastebin.com/raw/uNbmb05w . It's easy to understand, first it copies all the files to the ramdisk, then , every 60 seconds it updates the files in the HDD with the ones on the ramdisk. You may change that value if you wish.

To download it , we run :

curl -L https://pastebin.com/raw/uNbmb05w > /usr/local/bin/boinc-prst.sh

And we make it executable

chmod 644 /usr/local/bin/boinc-prst.sh

Now we must create a systemd service for it.. Again i created it for you : https://pastebin.com/raw/JQ2w7XU7

curl -L https://pastebin.com/raw/JQ2w7XU7 > /usr/lib/systemd/system/boinc-prst.service

And now we must activate boinc. systemd dependency resolutor should take care of the rest

systemctl enable boinc-ram

Now reboot and done are we.

Sort:  

Hey you should try use markup for the cli snippets. You can check this post on the topic: https://steemit.com/steemit/@sisygoboom/the-ultimate-guide-to-formatting-on-steemit-markup-and-markdown and you can edit and update a post on steemit.

Wow . TIL. Will update it when i get home.