-
-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Allow out-of-order incremental hashing
The memory cache enables us to support some level of out-of-order incremental hashing. If a block is still in the cache then we can incremental it! Once we have read the block from the cache it is flushed to disk. One potential race condition has been eliminated by keeping blocks available in the memory cache while they are being flushed to disk: The scenario is: -- Thread 1 writes a block to the cache. The cache is full. Thread pool choose the oldest unused block, removes it from the cache and then flushes it. Thread 2 then tries to read the block which thread 1 evicted. Thread 2 cannot find it in the memory cache. Thread 2 tries to read it from disk, but due to the lack of strong guarantess in the order in which async Tasks actually execute it's Read will be handled before Thread 1 actually writes the block to disk, which means Thread 2 unintentionally reads junk from disk. -- Now the blocks are guaranteed to be available in the cache until the corresponding IPieceWriter.WriteAsync invocation has completed. This makes out-of-order incremental hashing exceptionally effective and it's possible to download gigs of data using a 5MB memory cache and flush only a few kB of data to disk *before* it is incrementally hashed.
- Loading branch information
1 parent
0cf0c4e
commit a0de480
Showing
5 changed files
with
74 additions
and
14 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
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