From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 06/11] vinyl: zap vy_env::memory, read_threads, and write_threads Date: Thu, 20 Sep 2018 12:34:11 +0300 [thread overview] Message-ID: <5db02240fc79d6006e4adeec38609b94e118d8eb.1537435404.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1537435404.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1537435404.git.vdavydov.dev@gmail.com> They are only used to set corresponding members of vy_quota, vy_run_env, and vy_scheduler when vy_env is created. No point in keeping them around all the time. --- src/box/vinyl.c | 22 ++++++---------------- src/box/vy_run.c | 12 ++++++------ src/box/vy_run.h | 17 ++++++++++++----- test/unit/vy_point_lookup.c | 2 +- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 32143af0..4c1e860d 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -132,14 +132,8 @@ struct vy_env { int64_t join_lsn; /** Path to the data directory. */ char *path; - /** Max size of the memory level. */ - size_t memory; /** Max time a transaction may wait for memory. */ double timeout; - /** Max number of threads used for reading. */ - int read_threads; - /** Max number of threads used for writing. */ - int write_threads; /** Try to recover corrupted data if set. */ bool force_recovery; }; @@ -759,8 +753,7 @@ vinyl_index_open(struct index *index) rc = vy_lsm_create(lsm); if (rc == 0) { /* Make sure reader threads are up and running. */ - vy_run_env_enable_coio(&env->run_env, - env->read_threads); + vy_run_env_enable_coio(&env->run_env); } break; case VINYL_INITIAL_RECOVERY_REMOTE: @@ -2491,10 +2484,7 @@ vy_env_new(const char *path, size_t memory, } memset(e, 0, sizeof(*e)); e->status = VINYL_OFFLINE; - e->memory = memory; e->timeout = TIMEOUT_INFINITY; - e->read_threads = read_threads; - e->write_threads = write_threads; e->force_recovery = force_recovery; e->path = strdup(path); if (e->path == NULL) { @@ -2510,8 +2500,8 @@ vy_env_new(const char *path, size_t memory, if (e->squash_queue == NULL) goto error_squash_queue; - vy_mem_env_create(&e->mem_env, e->memory); - vy_scheduler_create(&e->scheduler, e->write_threads, + vy_mem_env_create(&e->mem_env, memory); + vy_scheduler_create(&e->scheduler, write_threads, vy_env_dump_complete_cb, &e->run_env, &e->xm->read_views); @@ -2520,14 +2510,14 @@ vy_env_new(const char *path, size_t memory, vy_squash_schedule, e) != 0) goto error_lsm_env; - if (vy_quota_create(&e->quota, e->memory, vy_env_trigger_dump_cb) != 0) + if (vy_quota_create(&e->quota, memory, vy_env_trigger_dump_cb) != 0) goto error_quota; struct slab_cache *slab_cache = cord_slab_cache(); mempool_create(&e->iterator_pool, slab_cache, sizeof(struct vinyl_iterator)); vy_cache_env_create(&e->cache_env, slab_cache); - vy_run_env_create(&e->run_env); + vy_run_env_create(&e->run_env, read_threads); vy_log_init(e->path); return e; error_quota: @@ -2819,7 +2809,7 @@ vinyl_engine_end_recovery(struct engine *engine) * creation, see vinyl_index_open(). */ if (e->lsm_env.lsm_count > 0) - vy_run_env_enable_coio(&e->run_env, e->read_threads); + vy_run_env_enable_coio(&e->run_env); e->status = VINYL_ONLINE; return 0; diff --git a/src/box/vy_run.c b/src/box/vy_run.c index f107e3a9..975b6349 100644 --- a/src/box/vy_run.c +++ b/src/box/vy_run.c @@ -123,12 +123,11 @@ vy_run_reader_f(va_list ap) /** Start run reader threads. */ static void -vy_run_env_start_readers(struct vy_run_env *env, int threads) +vy_run_env_start_readers(struct vy_run_env *env) { - assert(threads > 0); assert(env->reader_pool == NULL); + assert(env->reader_pool_size > 0); - env->reader_pool_size = threads; env->reader_pool = calloc(env->reader_pool_size, sizeof(*env->reader_pool)); if (env->reader_pool == NULL) @@ -166,9 +165,10 @@ vy_run_env_stop_readers(struct vy_run_env *env) * Initialize vinyl run environment */ void -vy_run_env_create(struct vy_run_env *env) +vy_run_env_create(struct vy_run_env *env, int read_threads) { memset(env, 0, sizeof(*env)); + env->reader_pool_size = read_threads; tt_pthread_key_create(&env->zdctx_key, vy_free_zdctx); mempool_create(&env->read_task_pool, cord_slab_cache(), sizeof(struct vy_page_read_task)); @@ -190,11 +190,11 @@ vy_run_env_destroy(struct vy_run_env *env) * Enable coio reads for a vinyl run environment. */ void -vy_run_env_enable_coio(struct vy_run_env *env, int threads) +vy_run_env_enable_coio(struct vy_run_env *env) { if (env->reader_pool != NULL) return; /* already enabled */ - vy_run_env_start_readers(env, threads); + vy_run_env_start_readers(env); } /** diff --git a/src/box/vy_run.h b/src/box/vy_run.h index 5030886c..5d9865e4 100644 --- a/src/box/vy_run.h +++ b/src/box/vy_run.h @@ -281,9 +281,13 @@ struct vy_page { /** * Initialize vinyl run environment + * + * @param read_threads - max number of background threads to + * use for disk reads; note background threads are not used + * until vy_run_env_enable_coio() is called. */ void -vy_run_env_create(struct vy_run_env *env); +vy_run_env_create(struct vy_run_env *env, int read_threads); /** * Destroy vinyl run environment @@ -294,14 +298,17 @@ vy_run_env_destroy(struct vy_run_env *env); /** * Enable coio reads for a vinyl run environment. * - * This function starts @threads reader threads and makes - * the run iterator hand disk reads over to them rather than - * read run files directly blocking the current fiber. + * This function starts background reader threads and makes + * the run iterator hand disk reads over to them rather + * than read run files directly blocking the current fiber. + * + * The number of background reader threads is configured when + * the environment is created, see vy_run_env_create(). * * Subsequent calls to this function will silently return. */ void -vy_run_env_enable_coio(struct vy_run_env *env, int threads); +vy_run_env_enable_coio(struct vy_run_env *env); /** * Return the size of a run bloom filter. diff --git a/test/unit/vy_point_lookup.c b/test/unit/vy_point_lookup.c index 86877d7d..dd33bbec 100644 --- a/test/unit/vy_point_lookup.c +++ b/test/unit/vy_point_lookup.c @@ -70,7 +70,7 @@ test_basic() is(rc, 0, "vy_lsm_env_create"); struct vy_run_env run_env; - vy_run_env_create(&run_env); + vy_run_env_create(&run_env, 0); struct vy_cache_env cache_env; vy_cache_env_create(&cache_env, slab_cache); -- 2.11.0
next prev parent reply other threads:[~2018-09-20 9:34 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-09-20 9:34 [PATCH 00/11] vinyl: prepare for transaction throttling Vladimir Davydov 2018-09-20 9:34 ` [PATCH 01/11] vinyl: merge vy_quota_release and vy_quota_update_dump_bandwidth Vladimir Davydov 2018-09-20 9:34 ` [PATCH 02/11] vinyl: refactor quota use/unuse methods Vladimir Davydov 2018-09-20 9:34 ` [PATCH 03/11] vinyl: do not try to trigger dump if it is already in progress Vladimir Davydov 2018-09-20 9:34 ` [PATCH 04/11] vinyl: don't start quota timer until local recovery is complete Vladimir Davydov 2018-09-20 9:34 ` [PATCH 05/11] vinyl: add helper to start scheduler and enable quota on startup Vladimir Davydov 2018-09-25 23:22 ` [tarantool-patches] " Konstantin Osipov 2018-09-20 9:34 ` Vladimir Davydov [this message] 2018-09-25 23:23 ` [tarantool-patches] Re: [PATCH 06/11] vinyl: zap vy_env::memory, read_threads, and write_threads Konstantin Osipov 2018-09-20 9:34 ` [PATCH 07/11] vinyl: do not account zero dump bandwidth Vladimir Davydov 2018-09-25 23:24 ` [tarantool-patches] " Konstantin Osipov 2018-09-20 9:34 ` [PATCH 08/11] vinyl: set quota timer period to 100 ms Vladimir Davydov 2018-09-20 9:34 ` [PATCH 09/11] vinyl: implement basic transaction throttling Vladimir Davydov 2018-09-20 9:34 ` [PATCH 10/11] vinyl: implement quota wait queue without fiber_cond Vladimir Davydov 2018-09-20 9:34 ` [PATCH 11/11] vinyl: split quota consumption rate limit into soft and hard Vladimir Davydov 2018-09-25 23:19 ` [tarantool-patches] Re: [PATCH 00/11] vinyl: prepare for transaction throttling Konstantin Osipov
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=5db02240fc79d6006e4adeec38609b94e118d8eb.1537435404.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 06/11] vinyl: zap vy_env::memory, read_threads, and write_threads' \ /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