Eliminate unnecessary memory allocation in extended query protocol.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 12 Jun 2024 08:13:47 +0000 (17:13 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Wed, 12 Jun 2024 08:13:47 +0000 (17:13 +0900)
commita9d1df446893d88fc8476ca2f0a07ebb3efb5739
treeeb0b537f1c6085bcb65ed337ae18cca9d606298d
parent8c307f4bfafc1c92806bfebf75cd628d8952e7a3
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.
src/context/pool_session_context.c
src/protocol/pool_proto_modules.c