Potentially incorrect BUCKET/BLOCK ARRAY SIZE #360
StrongerXi
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Example
Environment
Tests compiled and executed in docker
Test case
Simply add the following "test" to
hash_table_page_test.cpp
, and run it.Relevant output:
Note that the real size of
TestBucketPage
issizeof(TestBucketPage) + BUCKET_ARRAY_SIZE * sizeof(MappingType) = 2 + 4095 = 4097
, which exceedsPAGE_SIZE = 4096
.Expected output:
Running in docker, we should expect to see the following:
However, when running on my machine (MacOS Big Sur 11.6, M1 chip), the program won't even compile, i.e., the following line would trigger an "array too large" error. Note this is actually helpful, since it prevents people from instantiating "too large" pages.
Explanation
First of all, consider these 2 size calculations:
As far as I can see, they are equivalent to
Now consider extensible hash table pages (same reasoning applies to linear hash table pages).
The real size of
HashTableBucketPage
isWhich gives us the following series of inequalities:
Which reduces down to the following constraint
Which means the
BUCKET_ARRAY_SIZE
should be defined as this:Proposal
hash_table_page_defs.h
into
Beta Was this translation helpful? Give feedback.
All reactions