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

dag: Support multiple files in put #4254

Merged
merged 3 commits into from
Oct 2, 2017
Merged

dag: Support multiple files in put #4254

merged 3 commits into from
Oct 2, 2017

Conversation

magik6k
Copy link
Member

@magik6k magik6k commented Sep 20, 2017

See #4234

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
test_expect_success "dag put multiple files" '
printf {\"foo\":\"bar\"} > a.json &&
printf {\"foo\":\"baz\"} > b.json &&
ipfs dag put a.json b.json > dag_put_out
Copy link

Choose a reason for hiding this comment

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

Awesome!

Will test this week how many files it can get at once w/o choking. Thanks a lot for adding this!

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.

Nice! Just need to fix the pin lock.

if !ok {
return nil, fmt.Errorf("expected a different object in marshaler")
fmt.Println(reflect.TypeOf(res.Output()))
Copy link
Member

Choose a reason for hiding this comment

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

Leftovers from debugging.

@@ -100,52 +97,86 @@ into an object of the specified format.
defer n.Blockstore.PinLock().Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

Given that you add the blocks/pin in a go routine, this needs to go somewhere else (i.e., in the go routine). Also, if you want to improve this slightly, it's probably best not to hold this lock while waiting on the client (either receiving or sending data).

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
@magik6k
Copy link
Member Author

magik6k commented Sep 20, 2017

Fixed

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.

LGTM

defer n.Blockstore.PinLock().Unlock()
}

b := n.DAG.Batch()
Copy link
Member

Choose a reason for hiding this comment

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

We should put all dag nodes being added into the same batch here, i would move this batch creation up above the start of the for loop.

Copy link
Member

Choose a reason for hiding this comment

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

Are you sure it is right thing to do? What if I start adding 100GB of DAGs?

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my thinking there, though we might just say that users should care about their batch sizes.

Copy link
Member

Choose a reason for hiding this comment

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

The DAG batch is size limited, it will autoflush if you put too many items into it

Copy link
Member Author

Choose a reason for hiding this comment

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

done


cid = nds[0].Cid()
if dopin {
n.Pinning.PinWithMode(cid, pin.Recursive)
Copy link
Member

Choose a reason for hiding this comment

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

Also, since we're batching, we should just gather up all the things we're going to pin into an array, pin them all at once at the end, then only call Pinning.Flush once

License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Copy link
Member

@whyrusleeping whyrusleeping left a comment

Choose a reason for hiding this comment

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

👍

@whyrusleeping whyrusleeping merged commit e49ce6c into master Oct 2, 2017
@whyrusleeping whyrusleeping deleted the feat/dag-batch branch October 2, 2017 08:35
@magik6k magik6k restored the feat/dag-batch branch November 27, 2017 03:34
@magik6k magik6k deleted the feat/dag-batch branch November 27, 2017 03:47
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.

4 participants