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

implement ipfs pin update #3846

Merged
merged 3 commits into from
May 18, 2017
Merged

implement ipfs pin update #3846

merged 3 commits into from
May 18, 2017

Conversation

whyrusleeping
Copy link
Member

Makes re-pinning a slightly changed dataset much faster

License: MIT
Signed-off-by: Jeromy jeromyj@gmail.com

@whyrusleeping
Copy link
Member Author

I'll want a solid review of the algorithm here

Copy link
Member

@Kubuxu Kubuxu left a comment

Choose a reason for hiding this comment

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

Would be also good to have sharness tests for it.

cmds.StringArg("to-path", true, false, "Path to new object to be pinned."),
},
Options: []cmds.Option{
cmds.BoolOption("unpin", "Remove the old pin.").Default(true),
Copy link
Member

Choose a reason for hiding this comment

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

What is the use case of update with no unpin?

Copy link
Member Author

Choose a reason for hiding this comment

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

Its if you want to use the optimized pinning functionality and still keep the old pin

Copy link
Member

Choose a reason for hiding this comment

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

Ahh, right, because it will piggy bank on the already pinned hashes.

sset := cid.NewSet()
for _, c := range diff {
if c.a == nil {
err := mdag.EnumerateChildrenAsync(ctx, mdag.GetLinksDirect(dserv), c.b, sset.Visit)
Copy link
Member

Choose a reason for hiding this comment

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

This line is really long

Copy link
Member Author

Choose a reason for hiding this comment

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

It is really tho?

Copy link
Member

Choose a reason for hiding this comment

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

aka. too wide for my vim setup.

}

type diffpair struct {
a, b *cid.Cid
Copy link
Member

Choose a reason for hiding this comment

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

I would rename it to old, new. It clears up a lot.

Copy link
Member Author

Choose a reason for hiding this comment

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

cant use 'new' lol, its a keyword

Copy link
Member

Choose a reason for hiding this comment

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

ouch, annoying

a, b *cid.Cid
}

func getLinkDiff(a, b node.Node) []diffpair {
Copy link
Member

Choose a reason for hiding this comment

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

It took me a minute to properly get what this function does but now I understand.

It diffs links as a set, it doesn't matter for it if some link is repeated.

return err
}
} else {
err := DiffEnumerate(ctx, dserv, c.a, c.b)
Copy link
Member

Choose a reason for hiding this comment

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

Are we worried here about too deep recursion? Should it be turned into loop with TODO list instead?

Copy link
Member

Choose a reason for hiding this comment

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

Also coverage shows that this isn't tested at all.

@kevina
Copy link
Contributor

kevina commented Mar 31, 2017

@whyrusleeping I would like to review this but it may take up to week before I can get to it.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

The algo from what I can tell looks solid. I would not use the phrase "edit distance" though as, at least for me, that made understanding what is going on more difficult than it needs to be.

type diffpair struct {
bef, aft *cid.Cid
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Although it is fairly easy to figure out, I would add a note on the meaning of bef and aft, something along the line of replace bef with aft if bef is nil, than insert aft.

bef, aft *cid.Cid
}

// getLinkDiff returns a changset (minimum edit distance style) between nodes
Copy link
Contributor

Choose a reason for hiding this comment

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

I was rather confused by what this is doing. From the code it is fairly clear but the phrase "minimum edit distance style" confused me. As someone who wrote a spell checker I was expecting a traditional edit dist algo, and was very confused my the use of the maps. I would probably have had an easier time understanding what is going on if I wasn't trying to reconcile the code with what a traditional string edit dist. algo would be doing.

pin/pin.go Outdated
// Update updates a recursive pin from one cid to another
// this is more efficient than simply pinning the new one and unpinning the
// old one
Update(context.Context, *cid.Cid, *cid.Cid, bool) error
Copy link
Contributor

Choose a reason for hiding this comment

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

I would name the parameters here. The use of the bool in Update differs from the use in pin and unpin.

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

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

Needs a rebase but other then that it LGTM now.

License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
License: MIT
Signed-off-by: Jeromy <jeromyj@gmail.com>
@whyrusleeping whyrusleeping merged commit 8e2aed3 into master May 18, 2017
@whyrusleeping whyrusleeping removed the status/in-progress In progress label May 18, 2017
@Kubuxu Kubuxu deleted the feat/pin-update branch August 10, 2017 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants