jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.78k stars 837 forks source link

minimize memory allocations in sanitize #2124

Open vtolstov opened 1 month ago

vtolstov commented 1 month ago

I'm using pgbouncer with pgx and saw many memory allocs in internal/sanitize packages. Did you mind to use simple buffer pool for this https://github.com/jackc/pgx/blob/v4.18.3/internal/sanitize/sanitize.go#L29

So you can use already allocated buffer and reuse it all the time, so we can minimise garbage collector cpu time and also minimise memory usage.

jackc commented 1 month ago

v4 is not getting any changes except bug fixes.

vtolstov commented 1 month ago

What about v5 ?

jackc commented 1 month ago

Yes, it would be reasonable for v5.

ninedraft commented 1 month ago

If no one minds, I'd like to address this issue.

vtolstov commented 1 month ago

@ninedraft if you have free time this will be very helpful.