Wave field synthesis: Difference between revisions
en>Oelwiki |
|||
Line 1: | Line 1: | ||
{{for|file system fragmentation|file fragmentation}} | |||
{{Multiple issues | |||
|technical = September 2010 | |||
|citation style = April 2011 | |||
|no footnotes = April 2011}} | |||
In [[computer storage]], '''fragmentation''' is a phenomenon in which storage space is used inefficiently, reducing capacity or performance and often both. The exact consequences of fragmentation depend on the specific system of storage allocation in use and the particular form of fragmentation. In many cases, fragmentation leads to storage space being "wasted", and in that case the term also refers to the wasted space itself. For other systems (e.g. the [[File_Allocation_Table|FAT]] file system) the space used to store given data (e.g. files) is the same regardless of the degree of fragmentation (from none to extreme). | |||
There are three different but related forms of fragmentation: external fragmentation, internal fragmentation, and data fragmentation, which can be present in isolation or conjunction. Fragmentation is often accepted in return for improvements in speed or simplicity. | |||
==Basic principle== | |||
When a [[computer program]] requests blocks of memory from the computer system, the blocks are allocated in chunks. When the computer program is finished with a chunk, it can free the chunk back to the system, making it available to later be allocated again to another or the same program. The size and the amount of time a chunk is held by a program varies. During its lifespan, a computer program can request and free many chunks of memory. | |||
When a program is started, the free memory areas are long and contiguous. Over time and with use, the long contiguous regions become fragmented into smaller and smaller contiguous areas. Eventually, it may become impossible for the program to be obtain large contiguous chunks of memory. | |||
==Types of fragmentation== | |||
===Internal fragmentation=== | |||
Due to the rules governing [[memory allocation]], more computer memory is sometimes [[Memory allocation|allocated]] than is needed. For example, memory can only be provided to programs in chunks divisible by 4, 8 or 16, and as a result if a program requests perhaps 23 bytes, it will actually get a chunk of 24. When this happens, the excess memory goes to waste. In this scenario, the unusable memory is contained within an allocated region. This arrangement, termed fixed partitions, suffers from inefficient memory use - any process, no matter how small, occupies an entire partition. This waste is called '''internal fragmentation'''.<ref>{{cite web | |||
| url = http://www.pcguide.com/ref/hdd/file/part.htm | |||
| title = Partitioning, Partition Sizes and Drive Lettering | |||
| date = April 17, 2001 | |||
| publisher = The PC Guide | |||
| accessdate = 2012-01-20 | |||
}}</ref><ref>{{cite web | |||
| url = http://www.symantec.com/business/support/index?page=content&id=TECH107956&locale=en_US | |||
| title = Switches: Sector copy | |||
| date = 2001-01-14 <!-- | |||
| revised = 2010-09-10 --> | |||
| publisher = Symantec | |||
| accessdate = 2012-01-20 | |||
}}</ref> | |||
Unlike other types of fragmentation, internal fragmentation is difficult to reclaim; usually the best way to remove it is with a design change. For example, in [[dynamic memory allocation]], [[memory pool]]s drastically cut internal fragmentation by spreading the space overhead over a larger number of objects. | |||
===External fragmentation=== | |||
External fragmentation arises when free memory is separated into small blocks and is interspersed by allocated memory. It is a weakness of certain storage allocation algorithms, when they fail to order memory used by programs efficiently. The result is that, although free storage is available, it is effectively unusable because it is divided into pieces that are too small individually to satisfy the demands of the application. The term "external" refers to the fact that the unusable storage is outside the allocated regions. | |||
For example, consider a situation wherein a program allocates 3 continuous blocks of memory and then frees the middle block. The memory allocator can use this free block of memory for future allocations. However, it cannot use this block if the memory to be allocated is larger in size than this free block. | |||
External fragmentation also occurs in file systems as many files of different sizes are created, change size, and are deleted. The effect is even worse if a file which is divided into many small pieces is deleted, because this leaves similarly small regions of free spaces. | |||
{| class="wikitable" | |||
|- | |||
! 0x0000 !! 0x1000 !! 0x2000 !! 0x3000 !! 0x4000 !! 0x5000 !! Comments | |||
|- | |||
| || || || || || || Start with all memory available for allocation. | |||
|- | |||
| style="background-color:#F33" | A | |||
| style="background-color:#FC3" | B | |||
| style="background-color:#3F3" | C | |||
| || || || Allocated three blocks A, B, and C, of size 0x1000. | |||
|- | |||
| style="background-color:#F33" | A | |||
| | |||
| style="background-color:#3F3" | C | |||
| || || || Freed block B. Notice that the memory that B used cannot be included for an allocation larger than B's size. | |||
|} | |||
===Data fragmentation=== | |||
'''Data fragmentation''' occurs when a collection of data in memory is broken up into many pieces that are not close together. It is typically the result of attempting to insert a large object into storage that has already suffered external fragmentation. | |||
For example, files in a [[file system]] are usually managed in units called ''[[Block (data storage)|blocks]]'' or [[Data cluster|clusters]]. When a file system is created, there is free space to store file blocks together [[contiguous]]ly. This allows for rapid sequential file reads and writes. However, as files are added, removed, and changed in size, the free space becomes externally fragmented, leaving only small holes in which to place new data. When a new file is written, or when an existing file is extended, the operating system puts the new data in new non-contiguous data blocks to fit into the available holes. The new data blocks are necessarily scattered, slowing access due to [[seek time]] and [[rotational latency]] of the read/write head, and incurring additional overhead to manage additional locations. This is called [[file system fragmentation]]. | |||
When writing a new file of a known size, if there are any empty holes that are larger than that file, the operating system can avoid data fragmentation by putting the file into any one of those holes. There are a variety of algorithms for selecting which of those potential holes to put the file; each of them is a [[heuristic#Computer science|heuristic]] approximate solution to the [[bin packing problem]]. The "best fit" algorithm chooses the smallest hole that is big enough. The "worst fit" algorithm chooses the largest hole. The "[[Bin packing problem#First-fit algorithm|first-fit algorithm]]" chooses the first hole that is big enough. The "next fit" algorithm keeps track of where each file was written. | |||
The "next fit" algorithm is faster than "first fit", which is in turn faster than "best fit", which is the same speed as "worst fit".<ref> | |||
D. Samanta. | |||
[http://books.google.com/books?id=_lDjLlasQycC&pg=PA76&lpg=PA76&dq=%22next+fit%22+%22first+fit%22+%22best+fit%22+%22worst+fit%22&source=bl&ots=LSuazNprap&sig=twfYA_YjVlcWpcO8E3UpgLalJ5c&hl=en&sa=X&ei=wKUFUMjuL5TW2wWa5MGsBQ&ved=0CE8Q6AEwAg#v=onepage&q=%22next%20fit%22%20%22first%20fit%22%20%22best%20fit%22%20%22worst%20fit%22&f=false "Classic Data Structures"] | |||
2004. | |||
p. 76 | |||
</ref> | |||
Just as compaction can eliminate external fragmentation, data fragmentation can be eliminated by rearranging data storage so that related pieces are close together. For example, the primary job of a [[defragmentation]] tool is to rearrange blocks on disk so that the blocks of each file are contiguous. Most defragmenting utilities also attempt to reduce or eliminate free space fragmentation. Some moving [[Garbage collection (computer science)|garbage collectors]] will also move related objects close together (this is called ''compacting'') to improve cache performance. | |||
There are 4 kinds of systems that never experience data fragmentation—they always store every file contiguously. | |||
Alas, all 4 kinds have significant disadvantages compared to systems that allow at least some temporary data fragmentation: | |||
*Simply write each file contiguously, as with [[CD-R]]. If there isn't already enough contiguous free space to hold the file, the system immediately fails to store the file—even when there are lots of little bits of free space from deleted files that add up to more than enough to store the file. | |||
*If there isn't already enough contiguous free space to hold the file, use a [[garbage collection (computer science)#Copying vs. mark-and-sweep vs. mark-and-don't-sweep|copying collector]] to convert many little bits of free space into one contiguous free region big enough to hold the file. This takes a lot more time than breaking the file up into fragments and putting those fragments into the available free space. | |||
*[[memory allocation#Fixed-size-blocks allocation|fixed-size-blocks allocation]]: write the file into any free block. If a programmer picks a fixed block size too small, the system immediately fails to store some files—files larger than the block size—even when there are many free blocks that add up to more than enough to store the file. If a programmer picks a block size too big, we waste a lot of space on internal fragmentation. | |||
*Some systems avoid dynamic allocation entirely, pre-allocating (contiguous) space for all possible files they will need—for example, [[MultiFinder]] pre-allocated a chunk of RAM to each application as it was started according to how much RAM that application's programmer claimed it would need. | |||
==Overview== | |||
Compared to external fragmentation, overhead and internal fragmentation account for little loss in terms of wasted memory and reduced performance. It is defined as: | |||
<big><math> {\text{External Memory Fragmentation} = 1 - } \frac{\text{Largest Block Of Free Memory}}{\text{Total Free Memory}} </math></big> | |||
Fragmentation of 0% means that all the free memory is in a single large block; fragmentation is 90% (for example) when 100 MB free memory is present but largest free block of memory for allocation is just 10 MB. | |||
External fragmentation tends to be less of a problem in file systems than in primary memory (RAM) allocation systems, because programs usually require their RAM allocation requests to be fulfilled with contiguous blocks, but file systems typically are designed to be able use any collection of available blocks (fragments) to assemble a file which logically appears contiguous. Therefore, if a highly fragmented file or many small files are deleted from a full volume and then a new file with size equal to the newly freed space is created, the new file will simply reuse the same fragments that were freed by the deletion. If what was deleted was one file, the new file and will be just as fragmented as that old file was, but in any case there will be no barrier to using all the (highly fragmented) free space to create the new file. In memory, on the other hand, the allocation systems used often cannot assemble a large block to meet a request from small noncontiguous free blocks, and so the request cannot be fulfilled and the program cannot proceed to do whatever it needed that memory for (unless it can reissue the request as a number of smaller separate requests). | |||
==Performance degradation due to fragmentation== | |||
Memory fragmentation is one of the most severe problems faced by [[system]] managers.{{cn|date=February 2013}} Over time, it leads to degradation of system performance. Eventually, memory fragmentation may lead to complete loss of free memory. | |||
Memory fragmentation is a [[Kernel (computing)|kernel]] [[Computer programming|programming]] level problem. During [[real-time computing]] of applications, fragmentation levels can reach as high as 99%, and may lead to system crashes or other instabilities.{{cn|date=February 2013}} This type of system crash can be difficult to avoid, as it is impossible to anticipate the critical rise in levels of memory fragmentation. However, while it may not be possible for a system to continue running all programs in the case of excessive memory fragmentation, a well-designed system should be able to recover from the critical fragmentation condition by moving in memory some memory blocks used by the system itself in order to enable consolidation of free memory into fewer, larger blocks, or, in the worst case, by terminating some programs to free their memory and then | |||
defragmenting the resulting sum total of free memory. This will at least avoid a true crash in the sense of system failure and allow the system to continue running some programs, save program data, etc. It is also important to note that fragmentation is a phenomenon of system software design; different software will be susceptible to fragmentation to different degrees, and it is possible to design a system that will never be forced to shut down or kill processes as a result of memory fragmentation. | |||
==See also== | |||
*[[Defragmentation]] | |||
*[[File system fragmentation]] | |||
*[[Memory management]] | |||
==References== | |||
{{reflist}} | |||
;General | |||
*http://www.edn.com/article/478952-Handling_memory_fragmentation.php | |||
*http://www.sqlservercentral.com/articles/performance+tuning/performancemonitoringbyinternalfragmentationmeasur/2014/ | |||
*C++ Footprint and Performance Optimization, R. Alexander; G. Bensley, Sams Publisher, First edition, Page no:128, ISBN no:9780672319044 | |||
*Ibid, Page no:129 | |||
==External links== | |||
*[http://csc.fsksm.utm.my/shukor/ndex.php?option=com_content&view=category&layout=blog&id=19 Videos explaining the concept of slack space], Department of Computer Systems and Communications, UTM | |||
{{Memory management navbox}} | |||
[[Category:File system management]] | |||
[[cs:Fragmentace (informatika)]] | |||
[[de:Fragmentierung (Informationstechnik)]] | |||
[[fr:Fragmentation (informatique)]] | |||
[[ko:단편화]] | |||
[[id:Fragmentasi (komputer)]] | |||
[[kk:Фрагментациялау]] | |||
[[nl:Fragmentatie]] | |||
[[ja:フラグメンテーション]] | |||
[[pl:Fragmentacja (system plików)]] | |||
[[pt:Fragmentação]] | |||
[[ru:Фрагментация]] | |||
[[sk:Fragmentácia (dátový nosič)]] | |||
[[sv:Fragmentering (datateknik)]] | |||
[[uk:Фрагментація (інформаційні технології)]] |
Revision as of 13:24, 10 December 2013
28 year-old Painting Investments Worker Truman from Regina, usually spends time with pastimes for instance interior design, property developers in new launch ec Singapore and writing. Last month just traveled to City of the Renaissance. Template:Multiple issues
In computer storage, fragmentation is a phenomenon in which storage space is used inefficiently, reducing capacity or performance and often both. The exact consequences of fragmentation depend on the specific system of storage allocation in use and the particular form of fragmentation. In many cases, fragmentation leads to storage space being "wasted", and in that case the term also refers to the wasted space itself. For other systems (e.g. the FAT file system) the space used to store given data (e.g. files) is the same regardless of the degree of fragmentation (from none to extreme).
There are three different but related forms of fragmentation: external fragmentation, internal fragmentation, and data fragmentation, which can be present in isolation or conjunction. Fragmentation is often accepted in return for improvements in speed or simplicity.
Basic principle
When a computer program requests blocks of memory from the computer system, the blocks are allocated in chunks. When the computer program is finished with a chunk, it can free the chunk back to the system, making it available to later be allocated again to another or the same program. The size and the amount of time a chunk is held by a program varies. During its lifespan, a computer program can request and free many chunks of memory.
When a program is started, the free memory areas are long and contiguous. Over time and with use, the long contiguous regions become fragmented into smaller and smaller contiguous areas. Eventually, it may become impossible for the program to be obtain large contiguous chunks of memory.
Types of fragmentation
Internal fragmentation
Due to the rules governing memory allocation, more computer memory is sometimes allocated than is needed. For example, memory can only be provided to programs in chunks divisible by 4, 8 or 16, and as a result if a program requests perhaps 23 bytes, it will actually get a chunk of 24. When this happens, the excess memory goes to waste. In this scenario, the unusable memory is contained within an allocated region. This arrangement, termed fixed partitions, suffers from inefficient memory use - any process, no matter how small, occupies an entire partition. This waste is called internal fragmentation.[1][2]
Unlike other types of fragmentation, internal fragmentation is difficult to reclaim; usually the best way to remove it is with a design change. For example, in dynamic memory allocation, memory pools drastically cut internal fragmentation by spreading the space overhead over a larger number of objects.
External fragmentation
External fragmentation arises when free memory is separated into small blocks and is interspersed by allocated memory. It is a weakness of certain storage allocation algorithms, when they fail to order memory used by programs efficiently. The result is that, although free storage is available, it is effectively unusable because it is divided into pieces that are too small individually to satisfy the demands of the application. The term "external" refers to the fact that the unusable storage is outside the allocated regions.
For example, consider a situation wherein a program allocates 3 continuous blocks of memory and then frees the middle block. The memory allocator can use this free block of memory for future allocations. However, it cannot use this block if the memory to be allocated is larger in size than this free block.
External fragmentation also occurs in file systems as many files of different sizes are created, change size, and are deleted. The effect is even worse if a file which is divided into many small pieces is deleted, because this leaves similarly small regions of free spaces.
0x0000 | 0x1000 | 0x2000 | 0x3000 | 0x4000 | 0x5000 | Comments |
---|---|---|---|---|---|---|
Start with all memory available for allocation. | ||||||
A | B | C | Allocated three blocks A, B, and C, of size 0x1000. | |||
A | C | Freed block B. Notice that the memory that B used cannot be included for an allocation larger than B's size. |
Data fragmentation
Data fragmentation occurs when a collection of data in memory is broken up into many pieces that are not close together. It is typically the result of attempting to insert a large object into storage that has already suffered external fragmentation.
For example, files in a file system are usually managed in units called blocks or clusters. When a file system is created, there is free space to store file blocks together contiguously. This allows for rapid sequential file reads and writes. However, as files are added, removed, and changed in size, the free space becomes externally fragmented, leaving only small holes in which to place new data. When a new file is written, or when an existing file is extended, the operating system puts the new data in new non-contiguous data blocks to fit into the available holes. The new data blocks are necessarily scattered, slowing access due to seek time and rotational latency of the read/write head, and incurring additional overhead to manage additional locations. This is called file system fragmentation.
When writing a new file of a known size, if there are any empty holes that are larger than that file, the operating system can avoid data fragmentation by putting the file into any one of those holes. There are a variety of algorithms for selecting which of those potential holes to put the file; each of them is a heuristic approximate solution to the bin packing problem. The "best fit" algorithm chooses the smallest hole that is big enough. The "worst fit" algorithm chooses the largest hole. The "first-fit algorithm" chooses the first hole that is big enough. The "next fit" algorithm keeps track of where each file was written. The "next fit" algorithm is faster than "first fit", which is in turn faster than "best fit", which is the same speed as "worst fit".[3]
Just as compaction can eliminate external fragmentation, data fragmentation can be eliminated by rearranging data storage so that related pieces are close together. For example, the primary job of a defragmentation tool is to rearrange blocks on disk so that the blocks of each file are contiguous. Most defragmenting utilities also attempt to reduce or eliminate free space fragmentation. Some moving garbage collectors will also move related objects close together (this is called compacting) to improve cache performance.
There are 4 kinds of systems that never experience data fragmentation—they always store every file contiguously. Alas, all 4 kinds have significant disadvantages compared to systems that allow at least some temporary data fragmentation:
- Simply write each file contiguously, as with CD-R. If there isn't already enough contiguous free space to hold the file, the system immediately fails to store the file—even when there are lots of little bits of free space from deleted files that add up to more than enough to store the file.
- If there isn't already enough contiguous free space to hold the file, use a copying collector to convert many little bits of free space into one contiguous free region big enough to hold the file. This takes a lot more time than breaking the file up into fragments and putting those fragments into the available free space.
- fixed-size-blocks allocation: write the file into any free block. If a programmer picks a fixed block size too small, the system immediately fails to store some files—files larger than the block size—even when there are many free blocks that add up to more than enough to store the file. If a programmer picks a block size too big, we waste a lot of space on internal fragmentation.
- Some systems avoid dynamic allocation entirely, pre-allocating (contiguous) space for all possible files they will need—for example, MultiFinder pre-allocated a chunk of RAM to each application as it was started according to how much RAM that application's programmer claimed it would need.
Overview
Compared to external fragmentation, overhead and internal fragmentation account for little loss in terms of wasted memory and reduced performance. It is defined as:
Fragmentation of 0% means that all the free memory is in a single large block; fragmentation is 90% (for example) when 100 MB free memory is present but largest free block of memory for allocation is just 10 MB.
External fragmentation tends to be less of a problem in file systems than in primary memory (RAM) allocation systems, because programs usually require their RAM allocation requests to be fulfilled with contiguous blocks, but file systems typically are designed to be able use any collection of available blocks (fragments) to assemble a file which logically appears contiguous. Therefore, if a highly fragmented file or many small files are deleted from a full volume and then a new file with size equal to the newly freed space is created, the new file will simply reuse the same fragments that were freed by the deletion. If what was deleted was one file, the new file and will be just as fragmented as that old file was, but in any case there will be no barrier to using all the (highly fragmented) free space to create the new file. In memory, on the other hand, the allocation systems used often cannot assemble a large block to meet a request from small noncontiguous free blocks, and so the request cannot be fulfilled and the program cannot proceed to do whatever it needed that memory for (unless it can reissue the request as a number of smaller separate requests).
Performance degradation due to fragmentation
Memory fragmentation is one of the most severe problems faced by system managers.Template:Cn Over time, it leads to degradation of system performance. Eventually, memory fragmentation may lead to complete loss of free memory.
Memory fragmentation is a kernel programming level problem. During real-time computing of applications, fragmentation levels can reach as high as 99%, and may lead to system crashes or other instabilities.Template:Cn This type of system crash can be difficult to avoid, as it is impossible to anticipate the critical rise in levels of memory fragmentation. However, while it may not be possible for a system to continue running all programs in the case of excessive memory fragmentation, a well-designed system should be able to recover from the critical fragmentation condition by moving in memory some memory blocks used by the system itself in order to enable consolidation of free memory into fewer, larger blocks, or, in the worst case, by terminating some programs to free their memory and then defragmenting the resulting sum total of free memory. This will at least avoid a true crash in the sense of system failure and allow the system to continue running some programs, save program data, etc. It is also important to note that fragmentation is a phenomenon of system software design; different software will be susceptible to fragmentation to different degrees, and it is possible to design a system that will never be forced to shut down or kill processes as a result of memory fragmentation.
See also
References
43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.
- General
- http://www.edn.com/article/478952-Handling_memory_fragmentation.php
- http://www.sqlservercentral.com/articles/performance+tuning/performancemonitoringbyinternalfragmentationmeasur/2014/
- C++ Footprint and Performance Optimization, R. Alexander; G. Bensley, Sams Publisher, First edition, Page no:128, ISBN no:9780672319044
- Ibid, Page no:129
External links
- Videos explaining the concept of slack space, Department of Computer Systems and Communications, UTM
Template:Memory management navbox
cs:Fragmentace (informatika) de:Fragmentierung (Informationstechnik) fr:Fragmentation (informatique) ko:단편화 id:Fragmentasi (komputer) kk:Фрагментациялау nl:Fragmentatie ja:フラグメンテーション pl:Fragmentacja (system plików) pt:Fragmentação ru:Фрагментация sk:Fragmentácia (dátový nosič) sv:Fragmentering (datateknik) uk:Фрагментація (інформаційні технології)
- ↑ Template:Cite web
- ↑ Template:Cite web
- ↑ D. Samanta. "Classic Data Structures" 2004. p. 76