Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

perf: improve actor storage performance #990

Merged
merged 0 commits into from
Sep 27, 2018
Merged

Conversation

dignifiedquire
Copy link
Contributor

This minimizes the amount of marshal & unmarshal calls being made when using actor.WithStorage.

I used the test TestTipSetWeightDeep as benchmark and went from 140s to 61s.

When applying ipfs/go-ipld-cbor#45 the time goes down to 45s.

First round for #979

Copy link
Contributor

@acruikshank acruikshank left a comment

Choose a reason for hiding this comment

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

WriteStorage and Put are on the boundary of the VM abstraction and golang typed data is not supposed to cross it. By the time we really need the abstraction, we'll have a whole new set of performance issues anyway. This optimization is significant, so I think it's worth a little flex.

@dignifiedquire dignifiedquire requested review from phritz and removed request for laser September 27, 2018 14:54

var retVal []byte
outErr, ok := out[len(out)-1].(error)
outErr, ok := out[len(out)-1].Interface().(error)
if ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if not ok? I realize this isn't something you introduced, just wondering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is the case below, that means it was nil and there was no error

func (s Storage) Put(v interface{}) (*cid.Cid, error) {
var nd format.Node
var err error
if blk, ok := v.(blocks.Block); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels pretty hacky to me, though I get why we're doing it and think we should. Do we agree that in the limit there should be one kind of thing that you pass to Put() and that optimizations should happen at a different level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree. The long term fix is making go-ipld-cbor much more intelligent and less wasteful. Then we can go back to nearly the same code we had before, modulo integrating that.

@dignifiedquire dignifiedquire merged commit ce40e9e into master Sep 27, 2018
@dignifiedquire dignifiedquire deleted the perf/actor-storage branch September 27, 2018 18:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants