[PYTHON] SSD swap operation check for Raspberry Pi OS 64bit β version

In the previous episode Raspberry Pi OS 64bit β version with portable SSD expansion swap, Swap was set for the SSD connected to the external USB. And this time, I confirmed the swap operation using the python program of the 10000th order equation of the previous Solving higher order equation with integer type.

The result is that even if Swap is moved to an SSD connected to an external USB, the python program of the 10000th equation runs on Thonny included in the Raspberry Pi OS 64bit beta version, and the memory swap function works normally. I was able to confirm that. The confirmation status is shown below.

swap start

Since Swap is moved to SSD, Swap is 0 at startup. In this state, only the main memory of the main unit is 8GB. Start Swap manually. The following two commands.

sudo dphys-swapfile setup 
sudo dphys-swapfile swapon

a.png

184.31GB appears in the total of Swap. Swap used is still 0 because it is just after Swap is started. There is 7.03GB of free main memory Mem. The shared, buff/cache, and available on the right are not mentioned this time.

Main memory depletion preprocessing

When there is free space in the main memory Mem, only the main memory Mem handles it. I don't use Swap. Swap will start running after the main memory Mem is exhausted. The theme this time is to check Swap operation while the python program is running. Therefore, before running the python program, perform preprocessing to exhaust the main memory Mem in advance. That way, when the python program starts running, the main memory Mem is already exhausted, so Swap will start running immediately. The preprocessing that actually exhausts the main memory Mem is just to open 10 760MB BMP images. The figure below is confirmed by command free. b0.png The free main memory Mem has been reduced to 135MB. And Swap used becomes 937MB, and you can see that Swap is starting to work.

Start Python program on Thonny

Start the python program of the 10000th order equation with Thonny included in the 64-bit beta version of Raspberry Pi OS. The figure below shows the command free just after the python program started. b.png Swap used is 1049MB, and you can see that Swap is working normally even while Thonny is running and the python program is running.

At the end of the calculation part

It is the time of Calculation Finished in the middle of programming the 10000th order equation. The figure below is confirmed by command free. c.png Swap used has increased to 1293MB.

At the end of the entire program

It is when the entire program of the 10000th order equation is finished. The figure below is confirmed by command free. d.png Swap used has increased to 1921MB. Also, the python program of the 10000th-order equation running on Thonny prints 10000 solutions and finishes normally.

All apps are closed and memory is released

10 760MB image files that were open with Thonny, when all apps were closed and memory was released. The figure below is confirmed by command free. e2.png Swap used has plummeted from 1921MB to 79MB. The free main memory Mem has recovered to 7.29GB.

As mentioned above, it was confirmed that Swap moved to SSD works normally even when the python program of the 10000th order equation is run on Thonny. Since the python program of the 10000th order equation itself takes 40 minutes, I was completely unaware of the 2-3 seconds swap-out time lag for every 100MB. Rather, it was of great significance that it was possible to avoid program outages due to the exhaustion of main memory.

Thank you for watching until the end.

Next time, in "Solving high equations with integer type = Distributed parallel processing =", we plan to try to shorten the calculation time by distributed processing using socket communication of 4 Raspberry Pis.

Recommended Posts

SSD swap operation check for Raspberry Pi OS 64bit β version
Portable SSD expansion swap setting for Raspberry Pi OS 64bit β version
Install docker-compose on 64-bit Raspberry Pi OS
VScode intellisense doesn't work on Raspberry Pi OS 64bit! (Python)
OS setup with Raspberry Pi Imager
Raspberry pi initial setting (for myself)
How to check Linux OS version