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

GH-41541: [Go][Parquet] Fix writer performance regression #41638

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/parquet/internal/encoding/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (b *PooledBufferWriter) Reserve(nbytes int) {
b.buf = bufferPool.Get().(*memory.Buffer)
}

newCap := utils.Max(b.buf.Cap()+b.offset, 256)
newCap := utils.Max(b.buf.Cap(), 256)
Copy link
Member

Choose a reason for hiding this comment

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

Why at least 256 more bytes should be reserved?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not "256 more bytes", it's giving a minimum. If you have a buffer which currently has less than 256 bytes as its capacity, we push its capacity to 256 in order to reduce future reallocations (since this is a buffer pool and we'll eventually reuse the buffer).

If this becomes an issue for anyone we can definitely make this configurable or reduce it. but it does go a long way to reduce small allocations if you're writing small row groups

for newCap < b.pos+nbytes {
newCap = bitutil.NextPowerOf2(newCap)
}
Expand Down
Loading