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

reuse buffer #453

Merged
merged 2 commits into from
Dec 16, 2021
Merged

reuse buffer #453

merged 2 commits into from
Dec 16, 2021

Conversation

tac0turtle
Copy link
Member

closes #371

cc @odeke-em

Copy link
Contributor

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

Nice work, thank you @marbar3778 and LGTM!

Copy link
Collaborator

@robert-zaremba robert-zaremba left a comment

Choose a reason for hiding this comment

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

totally forgot about this issue. Thanks for handling it.

@tac0turtle
Copy link
Member Author

getting a stack overflow in tests, any idea @odeke-em

@odeke-em
Copy link
Contributor

getting a stack overflow in tests, any idea @odeke-em

I just remembered that some of these functions return a byte slice []byte that'll be alive for who knows how long. However, we return buf.Bytes() which returns the raw underlying buffer. Looks like that's causing the problem. You can fix this by doing what I did here tendermint/tendermint#7325 and it'll still be much cheaper than creating and discarding a bytes.Buffer.

Copy link
Contributor

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

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

LGTM++ and thank you @marbar3778!

@tac0turtle tac0turtle merged commit 0568d39 into master Dec 16, 2021
@tac0turtle tac0turtle deleted the 371-reuse-buf branch December 16, 2021 12:43
prolenking pushed a commit to prolenking/iavl that referenced this pull request Aug 9, 2022
* reuse buffer

* copy bytes

(cherry picked from commit 0568d39)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants