Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

feat: switch to HAMT based on size #91

Merged
merged 9 commits into from
May 7, 2021

Conversation

schomatis
Copy link
Contributor

@schomatis schomatis commented May 6, 2021

Replace global binary UseHAMTSharding option with threshold (also global) one HAMTShardingSize that triggers the switch to HAMT based on estimated directory size.

Toward ipfs/go-mfs#87.

@schomatis schomatis requested a review from Stebalien May 6, 2021 22:52
@schomatis schomatis self-assigned this May 6, 2021
io/directory.go Outdated Show resolved Hide resolved
@schomatis schomatis force-pushed the schomatis/feat/size-switch-hamt branch from 53f4e21 to 7237e57 Compare May 6, 2021 23:07
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly small changes, otherwise LGTM.

io/directory.go Outdated Show resolved Hide resolved
io/directory.go Outdated Show resolved Hide resolved
// HAMTShardingSize option. We maintain this value even if the
// HAMTShardingSize is off since potentially the option could be activated
// on the fly.
estimatedSize int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's:

  1. Document the exact algorithm.
  2. Maybe call this "linkdataSize", or something equally inscrutable.

This "estimate" needs to accurately follow the algorithm to achieve convergence. While this is more of a "SHOULD" from a spec standpoint, I'd like to be as accurate as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full documentation is in the exported HAMTShardingSize (referenced here) which is what the user has access to; this is just an internal cache. I'd like to retain this name (or something similar to this effect) to better represent what we want to achieve (estimation of directory size) rather than the how (traversing links).

Also not following the talk about a spec (even if figuratively) and a reference to an algorithm which I'm not sure what part of the code it is designating (is it the addToEstimatedSize/removeFromEstimatedSize functions?).

All this said, if this is a blocking change feel free to push any documentation you want or rename however you prefer. Not very opinionated on this and it won't change how this PR works anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I just want something to indicate that this isn't just some random estimate that someone can just change, but that's not critical or merge blocking.

io/directory.go Outdated Show resolved Hide resolved
io/directory.go Outdated Show resolved Hide resolved
io/directory.go Outdated Show resolved Hide resolved
io/directory.go Show resolved Hide resolved
io/directory.go Outdated Show resolved Hide resolved
io/directory_test.go Outdated Show resolved Hide resolved
unixfs.go Show resolved Hide resolved
Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge when ready.

// HAMTShardingSize option. We maintain this value even if the
// HAMTShardingSize is off since potentially the option could be activated
// on the fly.
estimatedSize int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I just want something to indicate that this isn't just some random estimate that someone can just change, but that's not critical or merge blocking.

io/directory.go Outdated

func (d *BasicDirectory) addToEstimatedSize(name string, linkCid cid.Cid) {
d.estimatedSize += estimatedLinkSize(name, linkCid)
// FIXME: Ideally we may want to track the Link size as well but it is
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this FIXME, we don't want someone to actually come along and fix this in code (it's a spec change, effectively.

@schomatis schomatis merged commit 4a10174 into master May 7, 2021
@schomatis schomatis deleted the schomatis/feat/size-switch-hamt branch May 7, 2021 19:44
@schomatis schomatis restored the schomatis/feat/size-switch-hamt branch May 7, 2021 19:46
@schomatis schomatis mentioned this pull request Jun 1, 2021
4 tasks
@schomatis schomatis deleted the schomatis/feat/size-switch-hamt branch August 27, 2021 18:37
@aschmahmann aschmahmann mentioned this pull request Dec 1, 2021
80 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants