Skip to content
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

encode keys to datastore with base32 standard encoding #2903

Merged
merged 1 commit into from
Jul 1, 2016

Conversation

whyrusleeping
Copy link
Member

@whyrusleeping whyrusleeping commented Jun 24, 2016

This addresses #2601

Following this, we will need to:

License: MIT
Signed-off-by: Jeromy why@ipfs.io

@whyrusleeping
Copy link
Member Author

I'm in a bit of a conundrum. To merge this, we need to have a migration ready. Before i ship the migration i want to have really solid tests for it. Before i can write tests for the migrations, i need an easy way to install the new version.

@whyrusleeping
Copy link
Member Author

whyrusleeping commented Jun 28, 2016

@Kubuxu could you help me take a look at why these tests are failing? They pass locally without issue.

nevermind, the issue is that the docker tests are failing now. I love mutable build processes

@whyrusleeping whyrusleeping force-pushed the feat/dskey-encoding branch 2 times, most recently from ac7e6d9 to 5483a75 Compare June 28, 2016 05:31
syncfs := !r.config.Datastore.NoSync
blocksDS, err := flatfs.New(path.Join(r.path, flatfsDirectory), 4, syncfs)
blocksDS, err := flatfs.New(path.Join(r.path, flatfsDirectory), 7, syncfs)
Copy link
Contributor

Choose a reason for hiding this comment

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

@whyrusleeping I am not 100% sure, but I think this value should be 6 to preserve the original intent. Here is why, the initial '/' should not be base32 encoded so the original 4 bytes will now be

1 + 3*8/5 = 5.8 = 6 bytes

instead of

4*8/5 = 6.4 = 7 bytes

Copy link
Member Author

Choose a reason for hiding this comment

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

@kevina I don't think we were counting the initial slash before. That was (and is) getting cut off before being passed into the flatfs by the mount datastore

Copy link
Member Author

Choose a reason for hiding this comment

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

The initial goal here was to split to 256 different directories, which is 16 bytes. With a prefix length of 7 here, we get 14 bits to shard by.

7 bytes of prefix gets us 6 characters (yay slash), at 5 bits per character that gives us 30 bits. The first 16 bits are taken by the Qm prefix, leaving us 14 bits or 16384 way sharding. Dropping down to 6 bytes will leave us with 25 total bits, and 9 bits after the prefix == a 512 way sharding.

Thanks for making me do the math, youre right. (and I like 512 way sharding better than 256 way sharding that we had before)

Copy link
Contributor

Choose a reason for hiding this comment

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

@whyrusleeping it looks like you are correct in that the '/' is not included in the prefix count. The comment is misleading. That being said, I think 6 would be a better value in order to avoid too many directories for the average size repo. (I.e, it would be better to round down than up).

Copy link
Contributor

Choose a reason for hiding this comment

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

@whyrusleeping. Our messages crossed. It looks like the prefix was not included in the prefix length before ipfs/go-datastore#39 but now it is (see my comments on the pull request). I will leave it up to you to determine the best value. (To avoid too many directories I believe a smaller value would be better.)

@whyrusleeping whyrusleeping force-pushed the feat/dskey-encoding branch 2 times, most recently from a7c38af to 0805a9b Compare July 1, 2016 21:02
Fixes #2601

Also bump version to 0.4.3-dev

License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
@Kubuxu
Copy link
Member

Kubuxu commented Jul 1, 2016

It is just docker failure.

@whyrusleeping
Copy link
Member Author

@lgierth i thought we fixed the docker failure

@whyrusleeping
Copy link
Member Author

Mergin time.

Anyone who tries building from master after this merge will need to build the migrations and run them, at least until we put builds of the migrations up on dist.

syncfs := !r.config.Datastore.NoSync
blocksDS, err := flatfs.New(path.Join(r.path, flatfsDirectory), 4, syncfs)
// 5 bytes of prefix gives us 25 bits of freedom, 16 of which are taken by
// by the Qm prefix. Leaving us with 9 bits, or 512 way sharding
Copy link
Member

Choose a reason for hiding this comment

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

we'll want to go deeper later on

@jbenet
Copy link
Member

jbenet commented Aug 27, 2016

  • +1 for base32 instead of base64 (case sensitive fs-es!).
  • curious why not just hex? (so much faster). too long for paths?
  • curious why upper case? why not lowercase?

@Kubuxu
Copy link
Member

Kubuxu commented Aug 27, 2016

curious why not just hex? (so much faster). too long for paths?

IIRC the main concern was in memory size of keys, but filesystem path size was also a factor.

@jbenet
Copy link
Member

jbenet commented Aug 28, 2016

Sgtm thanks
On Sat, Aug 27, 2016 at 12:12 Jakub Sztandera notifications@github.com
wrote:

curious why not just hex? (so much faster). too long for paths?

IIRC the main concern was in memory size of keys, but filesystem path size
was also a factor.


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#2903 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAIcoaqRAPtt6dePcd8O4-zH1MIn_OArks5qkGHlgaJpZM4I-EXK
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants