-
Notifications
You must be signed in to change notification settings - Fork 37
feat: add config option to control fanout size #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a `shardFanoutBytes` option to the importer to allow configuring the number of bytes used for the HAMT prefix, also a test.
super(props, options) | ||
|
||
this._bucket = createHAMT({ | ||
hashFn: hamtHashFn, | ||
bits: 8 | ||
bits: options.shardFanoutBytes ?? 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsdoc description says default is 256 bytes, but it seems to be 1 byte here?
Also, is bits
really bytes
or do we need to do some math here?
@@ -123,6 +123,11 @@ export interface ImporterOptions extends ProgressOptions<ImporterProgressEvents> | |||
*/ | |||
shardSplitThresholdBytes?: number | |||
|
|||
/** | |||
* The maximum number of bytes used as a HAMT prefix for shard entries. Default: 256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default seems to be 8 bits (1 byte) above? change this comment, or actual default?
@@ -241,6 +246,7 @@ export async function * importer (source: ImportCandidateStream, blockstore: Wri | |||
|
|||
const wrapWithDirectory = options.wrapWithDirectory ?? false | |||
const shardSplitThresholdBytes = options.shardSplitThresholdBytes ?? 262144 | |||
const shardFanoutBytes = options.shardFanoutBytes ?? 8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 8 bytes the default, or 256?
Yeah, it shouldn't be "bytes". This is a typical problem with HAMT descriptions, we're dealing with different units and the UnixFS one makes it even harder by hex stringifying and then depending on the prefix length of the hex string!
|
Made my suggested changes in #357 - going with "bits" - the nice thing about using bits is that you don't have to worry about divisibility. You can't really do a fanout that's not a power of 2, so start low and power up from the bit count. |
It was |
* feat: add config option to control fanout size Adds a `shardFanoutBytes` option to the importer to allow configuring the number of bytes used for the HAMT prefix, also a test. * fix: use fanout "bits" (#357) --------- Co-authored-by: Rod Vagg <rod@vagg.org>
Adds a
shardFanoutBytes
option to the importer to allow configuring the number of bytes used for the HAMT prefix, also a test.