This is an automated email from the ASF dual-hosted git repository. yuxuan pushed a commit to branch revert-go-byte-pool in repository https://gitbox.apache.org/repos/asf/thrift.git
commit 36d4c5298f9ccd12281e6e1d2f456f6bb00719cd Author: Yuxuan 'fishy' Wang <[email protected]> AuthorDate: Wed May 1 09:17:09 2024 -0700 Revert "go: Define a bytePool for TRichTransport" This reverts commit 344498b67f42af38118cc250b0b1ec212f09d927. In our extreme case this actually made things worse. On 30s cpu profiles, although mallocgc reduced from 27.13s to 26.30s, the byte pool itself costed 11.9s. Looking at writeByte and readByte, writeByte increased from 3.69s to 5.89s, and readByte increased from 11.36s to 16.09s. --- lib/go/thrift/rich_transport.go | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/lib/go/thrift/rich_transport.go b/lib/go/thrift/rich_transport.go index f3d819e23..83fdf29f5 100644 --- a/lib/go/thrift/rich_transport.go +++ b/lib/go/thrift/rich_transport.go @@ -49,15 +49,9 @@ func (r *RichTransport) RemainingBytes() (num_bytes uint64) { return r.TTransport.RemainingBytes() } -var bytePool = newPool(nil, func(b *[1]byte) { - b[0] = 0 -}) - func readByte(r io.Reader) (c byte, err error) { - v := bytePool.get() - defer bytePool.put(&v) - - n, err := r.Read(v[:]) + v := [1]byte{0} + n, err := r.Read(v[0:1]) if n > 0 && (err == nil || errors.Is(err, io.EOF)) { return v[0], nil } @@ -71,10 +65,7 @@ func readByte(r io.Reader) (c byte, err error) { } func writeByte(w io.Writer, c byte) error { - v := bytePool.get() - defer bytePool.put(&v) - - v[0] = c - _, err := w.Write(v[:]) + v := [1]byte{c} + _, err := w.Write(v[0:1]) return err }
