go-mysql-org / go-mysql

a powerful mysql toolset with Go
MIT License
4.58k stars 976 forks source link

allow packet.Conn buffer size to be adjustable #892

Closed dvilaverde closed 3 months ago

dvilaverde commented 3 months ago

Our usage of this library is in an application that will maintain a few thousand active MySQL connections from a single instance and we've noticed that the application is holding a lot of memory in packet.Conn, specifically the bufio.Reader instances are holding about 500MB of the total 800MB heap.

This PR will allow our application to change the hardcoded 65536 buffer size to something more reasonable for our use case (maybe 4096), which should reduce our heap by at least 50%.