Description
I'm looking into reducing, or at least better understanding the memory footprint from pgx that a program I have takes up. The profile points to https://github.com/jackc/pgproto3/blob/master/bind.go#L134 being the main cause of memory allocations, which it looks like uses the wbuf in a pgconn to do the writing (looking at https://github.com/jackc/pgconn/blob/master/pgconn.go#L1110).
What I can't figure out is what the wbuf is for. I was looking at e948dc3 where it was added and I see it being appended into, but I don't see where it gets reset. I would have thought to see a
wbuf = wbuf[:0]
Somewhere to 'reuse' the write buffer. What am I missing?
Edit: Turns out I needed a rubber duck. I missed that wbuf was never being assigned the value of buf so it'd always be an empty slice.
In this case, my query strings are almost always larger than 1024 bytes, so there is still significant allocation overhead. This seems like something that could be promoted into a configuration variable?