-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the performance of cluster chain allocation (#68)
Improve cluster allocation by caching the last allocated cluster number. On FAT16 drives that have 64K clusters and are almost full, allocating new clusters is a very slow process. The entire FAT is scanned every time, and copying big files, a process that involves many allocations, takes an absurd amount of time. This commit introduces a mechanism that dramatically improves the performance of the process: - A new field named UD_ACLU is added to the unit descriptor. This field is initialized to 1 when the descriptor is created. - Whenever a cluster chain allocation happens, the process of searching free clusters doesn't start at cluster 2, instead it starts at the value stored at UD_ACLU plus one. - If the allocation process succeeds, UD_ACLU is updated to the number of the last cluster that has been allocated. - When a cluster chain is freed, UD_ACLU is updated to the lowest of the cluster numbers that have been freed minus one, but ONLY if that new value is lower than the previous value. This algorithm guarantees that the allocation process works as usual (the lowest numbered free clusters are allocated first), but much faster. Additionally, UD_ACLU is initialized to 1 again if: - The drive is written to by using the raw sector write RDABS or WRDRV function calls. - The allocation of a cluster chain fails (typically with a "disk full" error).
- Loading branch information
Showing
4 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters