summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorSwen Schillig <swen@vnet.ibm.com>2018-01-08 14:55:31 +0100
committerMartin Schwenke <martins@samba.org>2018-01-30 18:12:32 +0100
commit32d867cf09a15626b991be414ab6440f68953f35 (patch)
tree8ba36210166a57df23f78105cbc9a13a55a681f8 /ctdb
parenteae2d35fec071b020f420ba74ac6551c84140a4d (diff)
downloadsamba-32d867cf09a15626b991be414ab6440f68953f35.tar.gz
ctdb-common: Optimize sock_queue's memory managament
Make use of talloc pools for the sock_queue's memory requirements. Signed-off-by: Swen Schillig <swen@vnet.ibm.com> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Martin Schwenke <martins@samba.org> Autobuild-Date(master): Tue Jan 30 18:12:32 CET 2018 on sn-devel-144
Diffstat (limited to 'ctdb')
-rw-r--r--ctdb/common/sock_io.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ctdb/common/sock_io.c b/ctdb/common/sock_io.c
index ef7cfeb2ea1..51341ce023e 100644
--- a/ctdb/common/sock_io.c
+++ b/ctdb/common/sock_io.c
@@ -94,6 +94,17 @@ struct sock_queue {
size_t buflen, begin, end;
};
+/*
+ * The reserved talloc headers, SOCK_QUEUE_OBJ_COUNT,
+ * and the pre-allocated pool-memory SOCK_QUEUE_POOL_SIZE,
+ * are used for the sub-objects queue->im, queue->queue, queue->fde
+ * and queue->buf.
+ * If the memory allocating sub-objects of struct sock_queue change,
+ * those values need to be adjusted.
+ */
+#define SOCK_QUEUE_OBJ_COUNT 4
+#define SOCK_QUEUE_POOL_SIZE 2048
+
static bool sock_queue_set_fd(struct sock_queue *queue, int fd);
static void sock_queue_handler(struct tevent_context *ev,
struct tevent_fd *fde, uint16_t flags,
@@ -111,10 +122,12 @@ struct sock_queue *sock_queue_setup(TALLOC_CTX *mem_ctx,
{
struct sock_queue *queue;
- queue = talloc_zero(mem_ctx, struct sock_queue);
+ queue = talloc_pooled_object(mem_ctx, struct sock_queue,
+ SOCK_QUEUE_OBJ_COUNT, SOCK_QUEUE_POOL_SIZE);
if (queue == NULL) {
return NULL;
}
+ memset(queue, 0, sizeof(struct sock_queue));
queue->ev = ev;
queue->callback = callback;