From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 2/8] vinyl: don't use mempool for allocating background tasks Date: Tue, 4 Sep 2018 20:23:45 +0300 [thread overview] Message-ID: <c8170905e78392809e11832723d42695f79e6d3f.1536080993.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1536080993.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1536080993.git.vdavydov.dev@gmail.com> Background tasks are allocated infrequently, not more often than once per several seconds, so using mempool for them is unnecessary and only clutters vy_scheduler struct. Let's allocate them with malloc(). --- src/box/vy_scheduler.c | 14 +++++--------- src/box/vy_scheduler.h | 4 ---- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c index 367c8a20..fc4fdf8c 100644 --- a/src/box/vy_scheduler.c +++ b/src/box/vy_scheduler.c @@ -36,7 +36,6 @@ #include <stddef.h> #include <stdint.h> #include <stdlib.h> -#include <small/mempool.h> #include <small/rlist.h> #include <tarantool_ev.h> @@ -233,10 +232,10 @@ static struct vy_task * vy_task_new(struct vy_scheduler *scheduler, struct vy_lsm *lsm, const struct vy_task_ops *ops) { - struct vy_task *task = mempool_alloc(&scheduler->task_pool); + struct vy_task *task = calloc(1, sizeof(*task)); if (task == NULL) { diag_set(OutOfMemory, sizeof(*task), - "mempool", "struct vy_task"); + "malloc", "struct vy_task"); return NULL; } memset(task, 0, sizeof(*task)); @@ -245,13 +244,13 @@ vy_task_new(struct vy_scheduler *scheduler, struct vy_lsm *lsm, task->lsm = lsm; task->cmp_def = key_def_dup(lsm->cmp_def); if (task->cmp_def == NULL) { - mempool_free(&scheduler->task_pool, task); + free(task); return NULL; } task->key_def = key_def_dup(lsm->key_def); if (task->key_def == NULL) { key_def_delete(task->cmp_def); - mempool_free(&scheduler->task_pool, task); + free(task); return NULL; } vy_lsm_ref(lsm); @@ -270,7 +269,7 @@ vy_task_delete(struct vy_task *task) key_def_delete(task->key_def); vy_lsm_unref(task->lsm); diag_destroy(&task->diag); - mempool_free(&task->scheduler->task_pool, task); + free(task); } static bool @@ -397,8 +396,6 @@ vy_scheduler_create(struct vy_scheduler *scheduler, int write_threads, fiber_cond_create(&scheduler->scheduler_cond); scheduler->worker_pool_size = write_threads; - mempool_create(&scheduler->task_pool, cord_slab_cache(), - sizeof(struct vy_task)); stailq_create(&scheduler->idle_workers); stailq_create(&scheduler->processed_tasks); @@ -424,7 +421,6 @@ vy_scheduler_destroy(struct vy_scheduler *scheduler) vy_scheduler_stop_workers(scheduler); diag_destroy(&scheduler->diag); - mempool_destroy(&scheduler->task_pool); fiber_cond_destroy(&scheduler->dump_cond); fiber_cond_destroy(&scheduler->scheduler_cond); vy_dump_heap_destroy(&scheduler->dump_heap); diff --git a/src/box/vy_scheduler.h b/src/box/vy_scheduler.h index 89f8f170..db85711a 100644 --- a/src/box/vy_scheduler.h +++ b/src/box/vy_scheduler.h @@ -34,9 +34,7 @@ #include <assert.h> #include <stdbool.h> #include <stdint.h> -#include <small/mempool.h> #include <small/rlist.h> -#include <tarantool_ev.h> #include "diag.h" #include "fiber_cond.h" @@ -74,8 +72,6 @@ struct vy_scheduler { int idle_worker_count; /** List of idle workers, linked by vy_worker::in_idle. */ struct stailq idle_workers; - /** Memory pool used for allocating vy_task objects. */ - struct mempool task_pool; /** Queue of processed tasks, linked by vy_task::in_processed. */ struct stailq processed_tasks; /** -- 2.11.0
next prev parent reply other threads:[~2018-09-04 17:23 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-02 20:18 [PATCH 0/7] vinyl: improve stats for throttling Vladimir Davydov 2018-09-02 20:18 ` [PATCH 1/7] vinyl: fix accounting of secondary index cache statements Vladimir Davydov 2018-09-02 22:26 ` [tarantool-patches] " Konstantin Osipov 2018-09-02 20:18 ` [PATCH 2/7] vinyl: add global memory stats Vladimir Davydov 2018-09-02 22:27 ` [tarantool-patches] " Konstantin Osipov 2018-09-02 22:27 ` Konstantin Osipov 2018-09-03 8:10 ` Vladimir Davydov 2018-09-02 20:18 ` [PATCH 3/7] vinyl: add global disk stats Vladimir Davydov 2018-09-02 22:30 ` [tarantool-patches] " Konstantin Osipov 2018-09-02 20:18 ` [PATCH 4/7] vinyl: fix force compaction logic Vladimir Davydov 2018-09-02 20:18 ` [PATCH 5/7] vinyl: update compact priority usual way on range split/coalesce Vladimir Davydov 2018-09-02 20:18 ` [PATCH 6/7] vinyl: keep track of compaction queue length and debt Vladimir Davydov 2018-09-02 20:19 ` [PATCH 7/7] vinyl: keep track of disk idle time Vladimir Davydov 2018-09-04 11:54 ` Vladimir Davydov 2018-09-04 17:23 ` Vladimir Davydov 2018-09-04 17:23 ` [PATCH 1/8] vinyl: add helper to check whether dump is in progress Vladimir Davydov 2018-09-06 7:33 ` Konstantin Osipov 2018-09-04 17:23 ` Vladimir Davydov [this message] 2018-09-06 7:33 ` [PATCH 2/8] vinyl: don't use mempool for allocating background tasks Konstantin Osipov 2018-09-04 17:23 ` [PATCH 3/8] vinyl: factor out worker pool from scheduler struct Vladimir Davydov 2018-09-06 7:34 ` Konstantin Osipov 2018-09-04 17:23 ` [PATCH 4/8] vinyl: move worker allocation closer to task creation Vladimir Davydov 2018-09-06 7:35 ` Konstantin Osipov 2018-09-04 17:23 ` [PATCH 5/8] vinyl: use separate thread pools for dump and compaction tasks Vladimir Davydov 2018-09-06 7:37 ` Konstantin Osipov 2018-09-06 9:48 ` Vladimir Davydov 2018-09-06 10:32 ` Konstantin Osipov 2018-09-04 17:23 ` [PATCH 6/8] vinyl: zap vy_worker_pool::idle_worker_count Vladimir Davydov 2018-09-06 7:38 ` Konstantin Osipov 2018-09-04 17:23 ` [PATCH 7/8] vinyl: don't start scheduler fiber until local recovery is complete Vladimir Davydov 2018-09-06 7:39 ` Konstantin Osipov 2018-09-04 17:23 ` [PATCH 8/8] vinyl: keep track of thread pool idle ratio Vladimir Davydov 2018-09-06 7:49 ` Konstantin Osipov 2018-09-06 8:18 ` Vladimir Davydov 2018-09-06 10:26 ` Konstantin Osipov 2018-09-06 10:52 ` Vladimir Davydov 2018-09-06 10:57 ` Konstantin Osipov 2018-09-06 11:59 ` Vladimir Davydov 2018-09-09 11:41 ` [PATCH 0/7] vinyl: improve stats for throttling Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=c8170905e78392809e11832723d42695f79e6d3f.1536080993.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 2/8] vinyl: don'\''t use mempool for allocating background tasks' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox