2

We are currently analyzing performance of some of our boxes at work and we find that we have boxes that are swapping a lot and things start crawling when that starts to happen cause we are using spinny disks.

I had a theory that it might actually be faster to start up brand a process and do all the initialization we would normally have to do for that than to wait for the process to have its memory loaded off of disk.

To test this theory out I want to force a process to swap to disk and I want to see how long it takes to respond after it has been swapped out and compare that to a new process start up, is there a way of forcing a process to swap without modifying swappiness settings or running the box out of memory?

I don't have root on these boxes so basically I need an unprivelaged way of doing/hint to the kernel to do this.

  • this sounds odd. You could be configuring your applications to have limits that avoid them arriving at the out of memory/swapped out scenario. To kill off a swapped out process cleanly it needs to be restored which is a bit harder with a brand new process consuming more ram. – danblack Nov 3 '18 at 1:30
  • @danblack That does not sound likely. There shouldn't be any need for the kernel to read back pages from swap when you have killed the process. It just need to clean up a few data structures and mark those pages of swap free, which all amounts to a few updates in kernel memory. – kasperd Nov 5 '18 at 13:06
1

Collect response time data of your actual applications, whatever you do. Log user response time, process start times, and whatever other performance metric is important to you.

On Linux, cgroups can have a memory limit beyond which processes in that group page out. A systemd service can set such a limit with the MemoryLimit directive, see the man page or RHEL's resource management guide. Remember that systemd units can be per user, root privilege not required.

Do not spend a lot of time trying to mock up a low memory condition, it is unlikely to perform like production's workload. If you can change the application to lazy starting or loading processes, do that in test then production. And measure the results.

0

Assumming this is Linux, you might want to set the swappiness variable to its MAX value. This basically tells the memory management to swap out everything possible that is not currently in use.

To permanently set:

 1.  Edit `/etc/sysconfig.conf`

 2.  add the following line to the file
      `vm.swappiness=100`

 3.  Reboot

Or to temporarily set till the next reboot:

 1. Enter the command
    `sudo sysctl vm.swappiness=10`

This will allow you to test your assumptions on your mix of jobs.

  • This is linux but I already said that I don't have root so this wont work – csteifel Nov 3 '18 at 0:39
  • Hmmm...the assumption is that posters in this group are administrators w/ root access. – mdpc Nov 13 '18 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.