[pgpool-committers: 9931] pgpool: Eliminate unnecessary memory allocation in extended query proto

Tatsuo Ishii ishii at sraoss.co.jp
Wed Jun 12 17:22:32 JST 2024


Eliminate unnecessary memory allocation in extended query protocol.

When pending messages are created, Pgpool-II did like:

(1) pmsg = pool_pending_message_create();       /* create a pending message */
(2) pool_pending_message_dest_set(pmsg, query_context)  /* set PostgreSQL node ids to be sent */
(3) pool_pending_message_query_set(pmsg, query_context);        /* add query context */
(4) pool_pending_message_add(pmsg);             /* add the pending message to the list */
(5) pool_pending_message_free_pending_message(pmsg);    /* free memory allocated by pool_pending_message_create();

The reason why pool_pending_message_free_pending_message(pmsg) is
called here is, pool_pending_message_add() creates a copy of the
pending message then add it to the list. This commit modifies
pool_pending_message_add() so that it does not create a copy of the
object and adds it to the pending messages list. This way, we can
eliminate (5) as well and it should reduce memory footprint and CPU
cycle.

Branch
------
master

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=a9d1df446893d88fc8476ca2f0a07ebb3efb5739

Modified Files
--------------
src/context/pool_session_context.c |  6 ++----
src/protocol/pool_proto_modules.c  | 15 ---------------
2 files changed, 2 insertions(+), 19 deletions(-)



More information about the pgpool-committers mailing list