I've read through quite some issues:
From https://zygo.github.io/bees/config.html we have the
unique data size | hash table size |average dedupe extent size
1TB | 4GB | 4K
1TB | 1GB | 16K
1TB | 256MB | 64K
1TB | 128MB | 128K <- recommended
1TB | 16MB | 1024K
64TB | 1GB | 1024K
From #192 you say
data-to-hash ratio falls between 1000:1 and 10000:1
and from #222 you say
A filesystem with 400 GB of data (uncompressed size) should have at hash table sized between 40MB and 400MB
which I assume means unique data size : hash table size should fall between 1000:1 to 10000:1
as in the table above, 1TB : 1GB = 1024:1, and 1TB : 128MB = 8192 : 1
Then we can have
hash_entries = hash table size / average dedupe extent size
hash_bytes = hash_entries * 16
hash_aligned = max(128 KiB, ceil(hash_bytes / 128 KiB) * 128 KiB)
Since the formular is linear, given any two of the three values unique data size hash table size average dedupe extent size, can calculate the other one.
And if the average dedupe extent size is determined, we have unique data size : hash table size determined.
Like 16K for 1TB : 1GB = 1024:1 or 100TiB : 100GiB, 128K for 1TB : 128MB = 8192 : 1.
And here's my question:
I know, that if the hash table size were to change, it's recommended to have the old .beeshome/beeshash.dat deleted and created through scan, all over (the tool to somehow make full reuse of old table doesn't exist yet), which could take tons of time with large unique data size.
If I were to have a file system with tozens of TiB, I think it would be not ideal to restart bees with a new hash table size (dynamically, every once in a while) and spend all those time to rebuild it. (I'm not really sure how fast is it... 50GiB for a night?)
So I want to use file system size as approximation of unique data size (the largest possible value), and use user's assumption of average file size as average dedupe extent size (approximate average extent size with dirty background bytes >= 128 MiB and no oflag=sync/oflag=dsync, then approximate average dedupe extent size).
Since in my understanding, a too large hash table mostly just waste RAM/storage space, but a too small hash table may severely influence deduplication efficiency. So for the reduplication efficiency's sake, it's more safe to assumingly set hash table larger, and it's fine to use file system size as approximation of unique data size.
I also think this can slightly make up for the inaccuracy from using (user's assumption of) average file size as average dedupe extent size, for that average file size will probably be larger than the average extent size, thus larger than average dedupe extent size. Since larger extent size means smaller hash table size, the optimized hash table size calculated out of the value, will be slightly smaller than it should be.
Anyway, then we have:
hash_entries = filesystem_size / avg_file_size
hash_bytes = hash_entries * 16
hash_aligned = max(128 KiB, ceil(hash_bytes / 128 KiB) * 128 KiB)
(filesystem_size ≈ unique data size
avg_file_size ≈ average dedupe extent size)
Do you have any suggestion to my approach?
Thank you for all those explains from the other issues.
And some less important rambles:
I'm also not really sure how compression affect the optimized hash table size. I know you suggest 2-4x larger. But if the average file size ≈ average extent size is already 128KiB, same as the largest value of compressed extent size, will it still need to be 2-4x larger? Maybe, to calculate the opimized hash table size, it'll still comes down to average dedupe extent size, just for the value to be influenced with the max size being 1024x smaller (from 128MiB to 128K).
Is it ideal to guess compression rate beforehand (Like "I'll start using normal zstd compress when my 50% storage is used") and set the value? If no compression is 1x, full compression is 2-4x larger, is there a (maybe linear) relationship for a file system with 50% compression rate ( one that started compression with that mount command half way), like the optimized hash table size is 0.5 * 2-4x?
Though this doesn't matter if I just determine the hash table size upon file system creation / first time bees starts and never change it no matter how I expand the system or start/close compression. I don't even know how to get current average extent size conveniently as of yet.
I also also kind of wonder if it's possible to calculate optimized hash table size, every once in a while, through compression rate and file system size (every time system expansion happens), so if new optimized hash table size is significantly different (like xxx% larger than current hash table size?) or that if current one got out of the range 1000:1-10000:1, I get a warning, and automatically calculate the expected time to scan all over(no idea as of yet as well), then find a time the system is free, and run a script to reboot bees with the new hash table size...
I've read through quite some issues:
From https://zygo.github.io/bees/config.html we have the
From #192 you say
data-to-hash ratio falls between 1000:1 and 10000:1and from #222 you say
A filesystem with 400 GB of data (uncompressed size) should have at hash table sized between 40MB and 400MBwhich I assume means
unique data size : hash table sizeshould fall between1000:1to10000:1as in the table above,
1TB : 1GB = 1024:1, and1TB : 128MB = 8192 : 1Then we can have
Since the formular is linear, given any two of the three values
unique data sizehash table sizeaverage dedupe extent size, can calculate the other one.And if the average dedupe extent size is determined, we have
unique data size : hash table sizedetermined.Like
16Kfor1TB : 1GB = 1024:1or100TiB : 100GiB, 128K for1TB : 128MB = 8192 : 1.And here's my question:
I know, that if the hash table size were to change, it's recommended to have the old
.beeshome/beeshash.datdeleted and created through scan, all over (the tool to somehow make full reuse of old table doesn't exist yet), which could take tons of time with large unique data size.If I were to have a file system with tozens of TiB, I think it would be not ideal to restart bees with a new hash table size (dynamically, every once in a while) and spend all those time to rebuild it. (I'm not really sure how fast is it... 50GiB for a night?)
So I want to use file system size as approximation of
unique data size(the largest possible value), and use user's assumption of average file size asaverage dedupe extent size(approximateaverage extent sizewith dirty background bytes >= 128 MiB and nooflag=sync/oflag=dsync, then approximateaverage dedupe extent size).Since in my understanding, a too large hash table mostly just waste RAM/storage space, but a too small hash table may severely influence deduplication efficiency. So for the reduplication efficiency's sake, it's more safe to assumingly set hash table larger, and it's fine to use file system size as approximation of
unique data size.I also think this can slightly make up for the inaccuracy from using (user's assumption of) average file size as
average dedupe extent size, for thataverage file sizewill probably be larger than theaverage extent size, thus larger thanaverage dedupe extent size. Since larger extent size means smaller hash table size, the optimized hash table size calculated out of the value, will be slightly smaller than it should be.Anyway, then we have:
(filesystem_size ≈ unique data size
avg_file_size ≈ average dedupe extent size)
Do you have any suggestion to my approach?
Thank you for all those explains from the other issues.
And some less important rambles:
I'm also not really sure how compression affect the optimized hash table size. I know you suggest 2-4x larger. But if the average file size ≈ average extent size is already 128KiB, same as the largest value of compressed extent size, will it still need to be 2-4x larger? Maybe, to calculate the opimized hash table size, it'll still comes down to
average dedupe extent size, just for the value to be influenced with the max size being 1024x smaller (from 128MiB to 128K).Is it ideal to guess compression rate beforehand (Like "I'll start using normal zstd compress when my 50% storage is used") and set the value? If no compression is 1x, full compression is 2-4x larger, is there a (maybe linear) relationship for a file system with 50% compression rate ( one that started compression with that mount command half way), like the optimized hash table size is 0.5 * 2-4x?
Though this doesn't matter if I just determine the hash table size upon file system creation / first time bees starts and never change it no matter how I expand the system or start/close compression. I don't even know how to get current average extent size conveniently as of yet.
I also also kind of wonder if it's possible to calculate optimized hash table size, every once in a while, through compression rate and file system size (every time system expansion happens), so if new optimized hash table size is significantly different (like xxx% larger than current hash table size?) or that if current one got out of the range 1000:1-10000:1, I get a warning, and automatically calculate the expected time to scan all over(no idea as of yet as well), then find a time the system is free, and run a script to reboot bees with the new hash table size...