Improve the performance of PixInsight with swap file storage

There is an easy way to increase the performance of PixInsight by optimising the swap file storage. I’ll explain a bit more about what it is and what it does, along with my personal tests and results in this article.
For those who are just interested in the improvement I’ll start with the short instruction what you’ll need to do.

Add Swap storage directories

In PixInsight, go to Edit -> Global Preferences. This will open up the Preferences window. In this window go to ‘Directories and Network’. You’ll see a window similar to the one shown below:

On the right hand side of the window you see a list of ‘Swap storage directories’. By default it will probably show something like ‘/tmp’. Now click the ‘Add’ button and add another (or the same!) directory. When clicking ‘Add’ it will open up the file browser where you can select a temp directory.
Repeat this a few times until you have between 4 and 8 directories listed.
Now your done!

If you’d like to understand what you just did and learn how you can further improve the swap performance, just read on below.

Swap file storage

PixInsight will use a lot of so called ‘swap storage’. This means that PixInsight will write temporary data to the disk of your computer and retrieve it again while executing certain processes. It’s often called an extension of the RAM memory that will be used, but it is important to realise that PixInsight will use the swap storage even when RAM memory is still available.
Without knowing anything else we can already appreciate the performance improvement you’ll get in PixInsight if you use fast disk drives like SSD or maybe even M2 drives; the faster PixInsight can write and read from the swap file storage, the faster it can execute the processes. The speed involved here is what we call ‘disk I/O’ or disk Input/Output. In some scenarios the processor might actually be waiting for some data to be retrieved from the swap storage. In such a case we are bottlenecked by the I/O speed of the disk. But what if we would have more disks available? In that case we could use parallel I/O operations to optimise the bandwith.
But even if you have only 1 disk available PixInsight will still be able to benefit in some cases from parallel I/O operations to the same disk. You could imagine scenarios where PI can write the output while retrieving some other data from the swap storage. This is especially the case when used with fast disks like SSD.
In order for PixInsight to be able to perform this parallel I/O operations, we simply need to add more swap storage folders like explained above.

RAM disk

Remember I mentioned earlier that PixInsight will use swap storage even if there is still RAM available. If you have enough room left in your RAM capacity you can make a so called ‘RAM disk’. This is a temporary disk you can create by using some of the RAM memory. Please remember that as soon as this disk is ejected or if you reboot or turn off your computer all stored files in this RAM disk will be gone! For swap file storage this is not a problem, but please do not mistake this for a regular disk.
On MacOS you can simply download this handy tool: RAM Disk Creator from Florian Bogner.
On Windows there are multiple programs available to do this, both free and paid software. This article has a benchmark of some of those applications to get you started.
Once you created the RAM disk you can simply access it like any other storage device. In order to enable PixInsight to use the RAM disk as swap storage you can simply add a folder on the RAM disk to the list of swap storage directories under Global Preferences. (as explained at the start of this article)

Using SSD and RAM disk simultaneously as swap file storage

You might be tempted to just use RAM disk as swap file storage because of the speed of a RAM disk versus an SSD device. However, you’ll need to make sure PixInsight will have enough swap storage available or it will start throwing errors. To prevent this you can simply add one folder from your regular storage in addition to the RAM disk. This will both enable parallel I/O operations and makes sure there is enough room for the swap files.

Testing results of parallel swap file storage

I ran the PixInsight benchmark with different swap file storage setups to check the impact of different configurations.
I ran the benchmark 5 times for each scenario and used the average results to determine the improvements compared to the default setup with only 1 entry under swap file storage which is 1 folder on a SSD in my case.
First I compared using different number of entries on the same SSD:

As you can see the actual increase for the Total score of the benchmark is not that great. As expected the CPU score isn’t impacted. However, when we check the improvement for the swap score we get this result:

I was somewhat surprised by the jump in performance when using 8 entries in stead of 6 or 10, but I was able to reproduce this and with 5 measurements per configuration I got a stable result within the same range every time.

No, let’s look what the performance increase is when we add a RAM disk in different configurations.
I have 16GB of RAM available on this system and noticed the total load almost never came above 8GB when running the benchmark. So I created a RAM disk of 8GB. However, the results were pretty bad! Apparently I had to little RAM left for the benchmark and the results were worse than before.
Next try: 6GB. This worked only if I also added a folder on the SSD or else I would run into disk space errors.
The 6GB did show improvement, but not as much as the 4GB did! This was surprising since the system monitor didn’t show loads that high for PixInsight, but apparently it performed better with 12GB RAM still available.
I got the biggest improvement when using 2 folders on the RAM disk of 4GB and 1 folder on the SSD.
See the graphs below for the actual results:

65% increase for the Swap score! That’s quite significance I’d say 🙂

So everyone that has a system with 16GB or more should seriously consider using a RAM disk for swap storage to improve the performance of PixInsight.

Free up RAM. (kill Chrome!)

If you are anything like me you probably have a ton of other applications and browser tabs open while working in PixInsight. Some necessary to read some tutorials and check examples, others not so necessary like watching YouTube while waiting for some PixInsight processes to finish. However, it can help your performance greatly if you kill most (unnecessary) programs while working in PixInsight. Especially Chrome is a notorious ‘RAM hogger’, so close it completely for better PixInsight performance!

Chrome uses A LOT of RAM.

Leave a Comment