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

add the ability to leverage zero-copy on blockstores. #75

Merged
merged 2 commits into from
Oct 30, 2020
Merged

Conversation

raulk
Copy link
Member

@raulk raulk commented Oct 30, 2020

Some datastores like badger offer a zero-copy query that loads an mmapped byte slice. For those, we can avoid the slice alloc + copy of the standard blockstore store get, but it's important that the byte slice does not escape, as it would be unsafe.

This patch introduces support for blockstores that support deserializing/processing the value in-place.

@welcome
Copy link

welcome bot commented Oct 30, 2020

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

store.go Outdated
if err != nil {
return err
}
f := func(b []byte) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we avoid the extra function call on each get?

We can do the direct atlas decode on the get path, and declare the same thing as a private method rather than an anonymous function that has to be re-allocated each Get that we use in the View case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty sure this would get inlined, but let me check.

Copy link
Member Author

Choose a reason for hiding this comment

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

No inlining happens, and Go benchmark shows that there's an extra alloc. I pushed 4c9b009 to incur in the (inevitable) callback alloc only in the zero-copy path.

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.

so good

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