Working set size (WSS) is a concept in computing that refers to the amount of memory required by a program or process to compute the answer to a problem over a given time interval. It is closely related to the working set model, a memory management strategy in operating systems introduced by Peter Denning in 1968.
Definition
In the context of operating systems and virtual memory management, the working set of a process at a given time is defined as the collection of memory pages referenced by the process during a recent time window. The working set size is the amount of memory (typically measured in pages or bytes) that constitutes this set—that is, the set of pages a process is actively using and that should remain resident in physical memory to avoid excessive page faults.
A broader definition from high-performance computing describes working set size as the amount of memory needed to compute the answer to a problem, encompassing both input data and intermediate data used during computation.
Significance
The working set size is significant because it determines how much physical memory a process requires to execute efficiently. Key implications include:
-
Thrashing prevention: If a process's working set size exceeds the available physical memory in a virtual memory system, the memory manager must swap pages between RAM and secondary storage (such as a hard disk) to continue execution. When this swapping occurs continuously, the system experiences a condition known as thrashing, which severely degrades performance.
-
Dynamic frame allocation: Operating systems may allocate a number of memory frames to a process equal to its working set size. This ensures that the pages a process is actively using remain in main memory, minimizing page faults and preventing thrashing.
-
Memory demand management: As a process's working set size increases, its memory demand increases. In systems like Windows, each process has minimum and maximum working set sizes that affect its virtual memory paging behavior.
The Working Set Model
The working set model, proposed by Peter Denning in his 1968 paper "The Working Set Model for Program Behavior," states that a process can reside in RAM if and only if all the pages it is currently using can fit in RAM. The model is "all or nothing": if a process's required pages exceed available RAM, the process is swapped out of memory to free space for other processes.
The working set model prevents thrashing while keeping the degree of multiprogramming as high as possible, thereby optimizing CPU utilization and throughput.
Implementation Considerations
Implementing the working set model requires tracking the working set over a moving time window. As each new memory reference occurs, the oldest references drop out of the window. To reduce overhead, the working set is often approximated by tracking the time of each page's last reference.
The working set itself is not a page replacement algorithm, but page replacement algorithms can be designed to avoid evicting pages that belong to a process's working set. One example is the WSClock algorithm, a modified version of the clock algorithm.
Variants
Working set can be subdivided into:
- Code working set and data working set: This distinction matters when code and data are stored separately in the memory hierarchy; if either working set exceeds the available cache or memory level, thrashing can occur.
- Process working set: For parallel programs, the set of processes that must be scheduled simultaneously for the program to make progress.
- Working set analogs exist for other limited resources, such as file handles and network sockets.
See Also
- Locality of reference
- Resident set size
- Virtual memory
- Page replacement algorithm
References
- Denning, Peter J. (1968). "The working set model for program behavior." Communications of the ACM, 11(5), 323–333.
- Denning, Peter J. (2021). "Working Set Analytics." ACM Computing Surveys, 53(6).
- Tanenbaum, Andrew (2009). Modern Operating Systems, Third Edition.
- Silberschatz, A., Galvin, P.B., & Gagne, G. (2005). Operating System Concepts, 7th edition.
- "Working set size." Wikipedia. https://en.wikipedia.org/wiki/Working_set_size.
- "Working set." Wikipedia. https://en.wikipedia.org/wiki/Working_set.