Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collapse PagedFile ref count and last page id
This reduces the number of volatile reads performed when pinning pages in the page cache. The numbers were initially separate variables, but have now been combined into a single volatile long field called the header state. So the header state includes both the reference count of the PagedFile – 15 bits – and the ID of the last page in the file – 48 bits, plus an empty file marker bit. Because our pages are usually 2^13 bytes, this means that we only loose 3 bits to the reference count, in terms of keeping large files byte addressable. The layout looks like this: ┏━ Empty file marker bit. When 1, the file is empty. ┃ ┏━ Reference count, 15 bites. ┃ ┃ ┏━ 48 bits for the last page id. ┃┏━━━┻━━━━━━━━━━┓ ┏━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ MRRRRRRR RRRRRRRR IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIIIII IIIIIIII 1 2 3 4 5 6 7 8 byte We then use masks and shifts when querying for either the reference count or the last page id. The page swapper will return -1 for the last page id, so during initialisation, we check for that, and initialises the header state to Long.MIN_VALUE to raise only the M bit. Because the reference count can now only hold a much smaller value than it could before, overflow checks have been added to the increments and decrements. This is fine, because those methods are only called infrequently.
- Loading branch information
Showing
8 changed files
with
166 additions
and
59 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
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
Oops, something went wrong.