请输入您要查询的百科知识:

 

词条 Thrashing (computer science)
释义

  1. Overview

     Causes 

  2. Other uses

  3. Possible solutions

  4. See also

  5. References

{{multiple issues|{{More footnotes|date=February 2010}}{{cleanup|reason=The language needs improvement|date=January 2015}}
}}

In computer science, thrashing occurs when a computer's virtual memory resources are overused, leading to a constant state of paging and page faults, inhibiting most application-level processing.[1] This causes the performance of the computer to degrade or collapse. The situation can continue indefinitely until either the user closes some running applications or the active processes free up additional virtual memory resources.

The term is also used for various similar phenomena, particularly movement between other levels of the memory hierarchy, where a process progresses slowly because significant time is being spent acquiring resources.

Overview

Virtual memory works by treating a portion of secondary storage such as a computer hard disk as an additional layer of the cache hierarchy. Virtual memory is notable for allowing processes to use more memory than is physically present in main memory and for enabling virtual machines. Operating systems supporting virtual memory assign processes a virtual address space and each process refers to addresses in its execution context by a so-called virtual address. In order to access data such as code or variables at that address, the process must translate the address to a physical address in a process known as virtual address translation. In effect, physical main memory becomes a cache for virtual memory which is in general stored on disk in memory pages.

Programs are allocated a certain number of pages as needed by the operating system. Active memory pages exist in both RAM and on disk. Inactive pages are removed from the cache and written to disk when the main memory becomes full.

If processes are utilizing all main memory and need additional memory pages, a cascade of severe cache misses known as page faults will occur, often leading to a noticeable lag in operating system responsiveness. This process together with the futile, repetitive page swapping that occurs are known as "thrashing". This frequently leads to high, runaway CPU utilization that can grind the system to a halt. In modern computers, thrashing may occur in the paging system (if there is not sufficient physical memory or the disk access time is overly long), or in the I/O communications subsystem (especially in conflicts over internal bus access), etc.

Depending on the configuration and algorithms involved, the throughput and latency of a system may degrade by multiple orders of magnitude. Thrashing is a state in which the CPU performs 'productive' work less, and 'swapping' more. The overall memory access time may increase since the higher level memory is only as fast as the next lower level in the memory hierarchy.[2] The CPU is busy in swapping pages so much that it can not respond to users' programs and interrupts as much as required. Thrashing occurs when there are too many pages in memory, and each page refers to another page. The real memory shortens in capacity to have all the pages in it, so it uses 'virtual memory'. When each page in execution demands that page that is not currently in real memory (RAM) it places some pages on virtual memory and adjusts the required page on RAM. If the CPU is too busy in doing this task, thrashing occurs.

Causes

In virtual memory systems, thrashing may be caused by programs or workloads that present insufficient locality of reference: if the working set of a program or a workload cannot be effectively held within physical memory, then constant data swapping, i.e., thrashing, may occur. The term was first used during the tape operating system days to describe the sound the tapes made when data was being rapidly written to and read.

An example of this sort of situation occurred on the IBM System/370 series mainframe computer, in which a particular instruction could consist of an execute instruction (which crosses a page boundary) that points to a move instruction (which itself also crosses a page boundary), targeting a move of data from a source that crosses a page boundary, to a target of data that also crosses a page boundary. The total number of pages thus being used by this particular instruction is eight, and all eight pages must be present in memory at the same time. If the operating system allocates fewer than eight pages of actual memory, when it attempts to swap out some part of the instruction or data to bring in the remainder, the instruction will again page fault, and it will thrash on every attempt to restart the failing instruction.

Other uses

Thrashing is best known in the context of memory and storage, but analogous phenomena occur for other resources, including:

{{visible anchor|Cache thrashing}}

Where main memory is accessed in a pattern that leads to multiple main memory locations competing for the same cache lines, resulting in excessive cache misses. This is most problematic for caches that have low associativity.

{{visible anchor|TLB thrashing}}

Where the translation lookaside buffer (TLB) acting as a cache for the memory management unit (MMU) which translates virtual addresses to physical addresses is too small for the working set of pages. TLB thrashing can occur even if instruction cache or data cache thrashing are not occurring, because these are cached in different sizes. Instructions and data are cached in small blocks (cache lines), not entire pages, but address lookup is done at the page level. Thus even if the code and data working sets fit into cache, if the working sets are fragmented across many pages, the virtual address working set may not fit into TLB, causing TLB thrashing.

{{visible anchor|Heap thrashing}}

Frequent garbage collection, due to failure to allocate memory for an object, due to insufficient free memory or insufficient contiguous free memory due to memory fragmentation is referred to as heap thrashing.[3]

{{visible anchor|Process thrashing}}

A similar phenomenon occurs for processes: when the process working set cannot be coscheduled – so not all interacting processes are scheduled to run at the same time – they experience "process thrashing" due to being repeatedly scheduled and unscheduled, progressing only slowly.[4]

Possible solutions

Using Hysteresis thresholding could help mitigate the issue (i.e.: one threshold for paging and another to go back to memory){{citation needed|date=August 2018}}.

See also

{{wikisource |The Paging Game}}
  • Page replacement algorithm
  • Congestion collapse
  • Resource contention
  • Out of memory
  • Software aging

References

1. ^{{cite journal|last = Denning | first = Peter J. | title = Thrashing: Its causes and prevention | journal= Proceedings AFIPS, Fall Joint Computer Conference |year = 1968 |url = http://www.cs.uwaterloo.ca/~brecht/courses/702/Possible-Readings/vm-and-gc/thrashing-denning-afips-1968.pdf | accessdate = 2012-02-15 | pages = 915–922 | volume = 33}}
2. ^{{Cite book|url=https://www.worldcat.org/oclc/755102367|title=Computer architecture : a quantitative approach|last=L.|first=Hennessy, John|date=2012|publisher=Morgan Kaufmann|others=Patterson, David A., Asanović, Krste.|isbn=9780123838728|edition= 5th|location=Waltham, MA|oclc=755102367}}
3. ^Performance Optimization and Tuning Techniques for IBM Processors, including IBM POWER8, [https://books.google.com/books?id=oxUBBAAAQBAJ&pg=PA170&dq="heap+thrashing" p. 170]
4. ^{{cite news|authorlink=John Ousterhout|first=J. K.|last=Ousterhout|url=http://web.stanford.edu/~ouster/cgi-bin/papers/coscheduling.pdf|title=Scheduling Techniques for Concurrent Systems|journal=Proceedings of Third International Conference on Distributed Computing Systems|year=1982|pages=22–30|ref=harv}}
{{DEFAULTSORT:Thrashing (Computer Science)}}

1 : Virtual memory

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/10 20:19:59