Thrashing Guide

Describes thrashing in terms of demand paging and how to prevent it.

Introduction

Thrashing is an undesirable state where most of the processes in the system are in the process of paging-in memory and none of the threads are doing useful work. This results in unacceptable system performance.

Background information

These topics are useful background information on thrashing:

  • Paging

  • Virtual memory

Thrashing features

The signs of thrashing in demand paging are:

  • The system performance rapidly becomes unacceptable, since no threads are doing useful work. The device will become unresponsive or appear to 'hang'.

  • When observing paging activity logs it's seen that the same set of pages are paged in and out many times over the course of a use case.

  • When observing paging activity logs there are long periods where many threads are waiting for pages to be paged in.

  • There are large periods of null thread activity.

Thrashing prevention

The following is a means of preventing thrashing from occurring:

  • Increase the size of the paging cache. This reduces page faults and hence the need to page-in memory.

  • Mark the code or data involved as unpaged, for example if a 20MB buffer is actively used through a use-case and discarded afterwards there is little use in making it paged as it will need to always be in the page cache.

  • Reduce the working set size so that it fits into the paging cache, for example instead of having four activities running concurrently, serialize them.