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

New option to reuse buffers when appending records #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yves57
Copy link

@Yves57 Yves57 commented Jan 22, 2021

If you have similar record lists to append to a file, reusing some internal slices saves memory and seems to significantly improve the performances.
On my computer:

Configuration
ReuseBuffers=false Deflate=false 81_858_921 ns/op 137_463_702 B/op 10_341 allocs/op
ReuseBuffers=true_Deflate=false 19_568_794 ns/op 21_023_761 B/op 10_051 allocs/op
ReuseBuffers=false_Deflate=true 261_185_675 ns/op 145_642_182 B/op 10_520 allocs/op
ReuseBuffers=true_Deflate=true 122_100_900 ns/op 9_794_948 B/op 10_223 allocs/op

The only strange thing is that reusing buffers takes less memory with deflate than without compression (but it is slower, which is consistent).

Do you think that it would interesting to add a such option?

deflateBlock = make([]byte, 0, len(block))
}

bb := bytes.NewBuffer(deflateBlock)
Copy link

Choose a reason for hiding this comment

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

may be in one style ?
var bb = bytes.NewBuffer(deflateBlock)

@xmcqueen
Copy link
Contributor

Hi are you still there? Are you still interested in discussing this PR?

@Yves57
Copy link
Author

Yves57 commented Sep 12, 2022

@xmcqueen Yes I'm still there. Do you have any remark/question?

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.

None yet

3 participants