You could disable the swap memory, providing that you have oodles of physical RAM to play with – although how wise that is, is debatable.
sysctl -a vm.compressor_mode
sudo nvram boot-args="vm_compressor=2"
From How Much Swap Memory Is Mac Using:
You can disable swap memory in Terminal on your Mac by typing the command lines sysctl -a vm.compressor_mode, and sudo nvram boot-args=”vm_compressor=2″ if the mode number is 4. After disabling swap memory, you should always monitor the usage of the RAM to avoid kernel panic on your Mac.
Some (slightly) better instructions from Save your M1 SSD by turning off Swap Memory
To start, you need to enter recovery mode (the following is for M1 chips only)
Shut down your Mac, and when its off, hold the power button until it
says “loading recovery” or something along those lines.Once you have continued into options, at the top, select utilities,
then terminal, and enter the following:
csrutil disable
enter your password, wait for it to complete, then restart.
Once logged back in, open terminal again, and enter the following:
sudo nvram boot-args="vm_compressor=2"
This will then turn the vm_compressor from 4 down to 2.
Shut down your computer again, hold down the power button and enter
the terminal (in recovery) as above.This time instead of disabling the csrutil, we will enable using the
following command:
csrutil enable
Once this is done, restart, open terminal, and check that your
cm_compressor is actually set to 2 by using the following:
sysctl -a vm.compressor_mode
If this has worked, watch in activity monitor that your swap memory
has almost gone to nothing!(there are a few warnings about kernel panic mode, but I have had zero
issues with 8gb of ram)
Note: I’ve not tried either of these methods.