[HACKERS] Custom allocators in libpq
От
Aaron Patterson
Тема
[HACKERS] Custom allocators in libpq
Дата
Msg-id
20170828172834.GA71455@TC.local
Список
Дерево обсуждения
[HACKERS] Custom allocators in libpq Aaron Patterson <tenderlove@ruby-lang.org>
Re: [HACKERS] Custom allocators in libpq Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Custom allocators in libpq Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Re: [HACKERS] Custom allocators in libpq Tom Lane <tgl@sss.pgh.pa.us>
Re: [HACKERS] Custom allocators in libpq Craig Ringer <craig@2ndquadrant.com>
Re: [HACKERS] Custom allocators in libpq Aaron Patterson <tenderlove@ruby-lang.org>
Hello! I would like to be able to configure libpq with custom malloc functions. The reason is that we have a Ruby wrapper that exposes libpq in Ruby. The problem is that Ruby's GC doesn't know how much memory has been allocated by libpq, so no pressure is applied to the GC when it should be. Ruby exports malloc functions that automatically apply GC pressure, and I'd like to be able to configure libpq to use those malloc functions. I've attached two patches that add this functionality. The first patch introduces a new function `PQunescapeByteaConn` which takes a connection (so we have a place to get the malloc functions). We already have `PQescapeBytea` and `PQescapeByteaConn`, this first patch gives us the analogous `PQunescapeBytea` and `PQunescapeByteaConn`. The second patch adds malloc function pointer fields to `PGEvent`, `pg_result`, and `pg_conn` structs, and changes libpq internals to use those allocators rather than directly calling `malloc`. This patch doesn't replace all malloc calls to the configured ones, just the mallocs related to creating result objects (which is what I'm concerned with). If there's something I'm missing, please let me know. This is my first patch to libpq, so I look forward to hearing feedback. Thanks for your time! -- Aaron Patterson http://tenderlovemaking.com/ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
В списке pgsql-hackers по дате отправления
От: Robert Haas
Дата: