From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: [PATCH 4/9] vinyl: rename lsm->range_heap to max_compaction_priority
Date: Mon, 21 Jan 2019 00:17:03 +0300 [thread overview]
Message-ID: <82a8ad14d24a705ca9e92176c27c9b072fb6a5b1.1548017258.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1548017258.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1548017258.git.vdavydov.dev@gmail.com>
The name 'range_heap' is ambiguous, because it's unclear what range
should be on top of the heap. We need to introduce another heap of
ranges ordered differently, so let's rename to max_compaction_priority
to avoid confusion.
---
src/box/vy_lsm.c | 24 ++++++++++++++----------
src/box/vy_lsm.h | 2 +-
src/box/vy_range.c | 2 +-
src/box/vy_range.h | 18 ++++++++++--------
src/box/vy_scheduler.c | 24 +++++++++++++-----------
5 files changed, 39 insertions(+), 31 deletions(-)
diff --git a/src/box/vy_lsm.c b/src/box/vy_lsm.c
index 5eb3fd77..851785ee 100644
--- a/src/box/vy_lsm.c
+++ b/src/box/vy_lsm.c
@@ -180,7 +180,7 @@ vy_lsm_new(struct vy_lsm_env *lsm_env, struct vy_cache_env *cache_env,
vy_cache_create(&lsm->cache, cache_env, cmp_def, index_def->iid == 0);
rlist_create(&lsm->sealed);
vy_range_tree_new(lsm->tree);
- vy_range_heap_create(&lsm->range_heap);
+ vy_max_compaction_priority_create(&lsm->max_compaction_priority);
rlist_create(&lsm->runs);
lsm->pk = pk;
if (pk != NULL)
@@ -257,7 +257,7 @@ vy_lsm_delete(struct vy_lsm *lsm)
vy_lsm_remove_run(lsm, run);
vy_range_tree_iter(lsm->tree, NULL, vy_range_tree_free_cb, NULL);
- vy_range_heap_destroy(&lsm->range_heap);
+ vy_max_compaction_priority_destroy(&lsm->max_compaction_priority);
tuple_format_unref(lsm->disk_format);
key_def_delete(lsm->cmp_def);
key_def_delete(lsm->key_def);
@@ -665,10 +665,12 @@ vy_lsm_generation(struct vy_lsm *lsm)
int
vy_lsm_compaction_priority(struct vy_lsm *lsm)
{
- struct heap_node *n = vy_range_heap_top(&lsm->range_heap);
- if (n == NULL)
+ struct heap_node *node;
+ node = vy_max_compaction_priority_top(&lsm->max_compaction_priority);
+ if (node == NULL)
return 0;
- struct vy_range *range = container_of(n, struct vy_range, heap_node);
+ struct vy_range *range = container_of(node, struct vy_range,
+ compaction_priority_node);
return range->compaction_priority;
}
@@ -732,8 +734,9 @@ vy_lsm_remove_run(struct vy_lsm *lsm, struct vy_run *run)
void
vy_lsm_add_range(struct vy_lsm *lsm, struct vy_range *range)
{
- assert(range->heap_node.pos == UINT32_MAX);
- vy_range_heap_insert(&lsm->range_heap, &range->heap_node);
+ assert(range->compaction_priority_node.pos == UINT32_MAX);
+ vy_max_compaction_priority_insert(&lsm->max_compaction_priority,
+ &range->compaction_priority_node);
vy_range_tree_insert(lsm->tree, range);
lsm->range_count++;
}
@@ -741,8 +744,9 @@ vy_lsm_add_range(struct vy_lsm *lsm, struct vy_range *range)
void
vy_lsm_remove_range(struct vy_lsm *lsm, struct vy_range *range)
{
- assert(range->heap_node.pos != UINT32_MAX);
- vy_range_heap_delete(&lsm->range_heap, &range->heap_node);
+ assert(range->compaction_priority_node.pos != UINT32_MAX);
+ vy_max_compaction_priority_delete(&lsm->max_compaction_priority,
+ &range->compaction_priority_node);
vy_range_tree_remove(lsm->tree, range);
lsm->range_count--;
}
@@ -1224,5 +1228,5 @@ vy_lsm_force_compaction(struct vy_lsm *lsm)
vy_lsm_acct_range(lsm, range);
}
- vy_range_heap_update_all(&lsm->range_heap);
+ vy_max_compaction_priority_update_all(&lsm->max_compaction_priority);
}
diff --git a/src/box/vy_lsm.h b/src/box/vy_lsm.h
index 74033627..a1d872e9 100644
--- a/src/box/vy_lsm.h
+++ b/src/box/vy_lsm.h
@@ -252,7 +252,7 @@ struct vy_lsm {
/** Number of ranges in this LSM tree. */
int range_count;
/** Heap of ranges, prioritized by compaction_priority. */
- heap_t range_heap;
+ heap_t max_compaction_priority;
/**
* List of all runs created for this LSM tree,
* linked by vy_run->in_lsm.
diff --git a/src/box/vy_range.c b/src/box/vy_range.c
index 87c4c6b9..a2cb4558 100644
--- a/src/box/vy_range.c
+++ b/src/box/vy_range.c
@@ -197,7 +197,7 @@ vy_range_new(int64_t id, struct tuple *begin, struct tuple *end,
}
range->cmp_def = cmp_def;
rlist_create(&range->slices);
- range->heap_node.pos = UINT32_MAX;
+ range->compaction_priority_node.pos = UINT32_MAX;
return range;
}
diff --git a/src/box/vy_range.h b/src/box/vy_range.h
index 05195d08..7c0a16e2 100644
--- a/src/box/vy_range.h
+++ b/src/box/vy_range.h
@@ -107,6 +107,8 @@ struct vy_range {
* how we decide how many runs to compact next time.
*/
int compaction_priority;
+ /** Link in vy_lsm->max_compaction_priority. */
+ struct heap_node compaction_priority_node;
/** Number of statements that need to be compacted. */
struct vy_disk_stmt_counter compaction_queue;
/**
@@ -121,8 +123,6 @@ struct vy_range {
int n_compactions;
/** Link in vy_lsm->tree. */
rb_node(struct vy_range) tree_node;
- /** Link in vy_lsm->range_heap. */
- struct heap_node heap_node;
/**
* Incremented whenever a run is added to or deleted
* from this range. Used invalidate read iterators.
@@ -134,15 +134,17 @@ struct vy_range {
* Heap of all ranges of the same LSM tree, prioritized by
* vy_range->compaction_priority.
*/
-#define HEAP_NAME vy_range_heap
+#define HEAP_NAME vy_max_compaction_priority
static inline bool
-vy_range_heap_less(struct heap_node *a, struct heap_node *b)
+vy_max_compaction_priority_less(struct heap_node *a, struct heap_node *b)
{
- struct vy_range *r1 = container_of(a, struct vy_range, heap_node);
- struct vy_range *r2 = container_of(b, struct vy_range, heap_node);
+ struct vy_range *r1 = container_of(a, struct vy_range,
+ compaction_priority_node);
+ struct vy_range *r2 = container_of(b, struct vy_range,
+ compaction_priority_node);
return r1->compaction_priority > r2->compaction_priority;
}
-#define HEAP_LESS(h, l, r) vy_range_heap_less(l, r)
+#define HEAP_LESS(h, l, r) vy_max_compaction_priority_less(l, r)
#include "salad/heap.h"
#undef HEAP_LESS
#undef HEAP_NAME
@@ -151,7 +153,7 @@ vy_range_heap_less(struct heap_node *a, struct heap_node *b)
static inline bool
vy_range_is_scheduled(struct vy_range *range)
{
- return range->heap_node.pos == UINT32_MAX;
+ return range->compaction_priority_node.pos == UINT32_MAX;
}
/**
diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index 5ec6d171..16ecafed 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -1228,7 +1228,7 @@ vy_task_dump_complete(struct vy_task *task)
vy_range_update_compaction_priority(range, &lsm->opts);
vy_lsm_acct_range(lsm, range);
}
- vy_range_heap_update_all(&lsm->range_heap);
+ vy_max_compaction_priority_update_all(&lsm->max_compaction_priority);
free(new_slices);
delete_mems:
@@ -1610,8 +1610,9 @@ vy_task_compaction_complete(struct vy_task *task)
/* The iterator has been cleaned up in worker. */
task->wi->iface->close(task->wi);
- assert(range->heap_node.pos == UINT32_MAX);
- vy_range_heap_insert(&lsm->range_heap, &range->heap_node);
+ assert(range->compaction_priority_node.pos == UINT32_MAX);
+ vy_max_compaction_priority_insert(&lsm->max_compaction_priority,
+ &range->compaction_priority_node);
vy_scheduler_update_lsm(scheduler, lsm);
say_info("%s: completed compacting range %s",
@@ -1642,8 +1643,9 @@ vy_task_compaction_abort(struct vy_task *task)
vy_run_discard(task->new_run);
- assert(range->heap_node.pos == UINT32_MAX);
- vy_range_heap_insert(&lsm->range_heap, &range->heap_node);
+ assert(range->compaction_priority_node.pos == UINT32_MAX);
+ vy_max_compaction_priority_insert(&lsm->max_compaction_priority,
+ &range->compaction_priority_node);
vy_scheduler_update_lsm(scheduler, lsm);
}
@@ -1657,14 +1659,14 @@ vy_task_compaction_new(struct vy_scheduler *scheduler, struct vy_worker *worker,
.abort = vy_task_compaction_abort,
};
- struct heap_node *range_node;
+ struct heap_node *node;
struct vy_range *range;
assert(!lsm->is_dropped);
- range_node = vy_range_heap_top(&lsm->range_heap);
- assert(range_node != NULL);
- range = container_of(range_node, struct vy_range, heap_node);
+ node = vy_max_compaction_priority_top(&lsm->max_compaction_priority);
+ assert(node != NULL);
+ range = container_of(node, struct vy_range, compaction_priority_node);
assert(range->compaction_priority > 1);
if (vy_lsm_split_range(lsm, range) ||
@@ -1722,8 +1724,8 @@ vy_task_compaction_new(struct vy_scheduler *scheduler, struct vy_worker *worker,
* Remove the range we are going to compact from the heap
* so that it doesn't get selected again.
*/
- vy_range_heap_delete(&lsm->range_heap, range_node);
- range_node->pos = UINT32_MAX;
+ vy_max_compaction_priority_delete(&lsm->max_compaction_priority, node);
+ node->pos = UINT32_MAX;
vy_scheduler_update_lsm(scheduler, lsm);
say_info("%s: started compacting range %s, runs %d/%d",
--
2.11.0
next prev parent reply other threads:[~2019-01-20 21:17 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-20 21:16 [PATCH 0/9] vinyl: compaction randomization and throttling Vladimir Davydov
2019-01-20 21:17 ` [PATCH 1/9] vinyl: update lsm->range_heap in one go on dump completion Vladimir Davydov
2019-01-24 16:55 ` Vladimir Davydov
2019-02-05 16:37 ` [tarantool-patches] " Konstantin Osipov
2019-01-20 21:17 ` [PATCH 2/9] vinyl: ignore unknown .run, .index and .vylog keys Vladimir Davydov
2019-01-24 16:56 ` Vladimir Davydov
2019-01-20 21:17 ` [PATCH 3/9] vinyl: use uncompressed run size for range split/coalesce/compaction Vladimir Davydov
2019-01-21 9:42 ` Vladimir Davydov
2019-02-05 16:49 ` [tarantool-patches] " Konstantin Osipov
2019-02-06 8:55 ` Vladimir Davydov
2019-02-06 10:46 ` Konstantin Osipov
2019-02-06 10:55 ` Vladimir Davydov
2019-02-05 16:43 ` Konstantin Osipov
2019-02-06 16:48 ` Vladimir Davydov
2019-01-20 21:17 ` Vladimir Davydov [this message]
2019-01-20 21:17 ` [PATCH 5/9] vinyl: keep track of dumps per compaction for each LSM tree Vladimir Davydov
2019-02-05 16:58 ` [tarantool-patches] " Konstantin Osipov
2019-02-06 9:20 ` Vladimir Davydov
2019-02-06 16:54 ` Vladimir Davydov
2019-01-20 21:17 ` [PATCH 6/9] vinyl: set range size automatically Vladimir Davydov
2019-01-22 9:17 ` Vladimir Davydov
2019-02-05 17:09 ` [tarantool-patches] " Konstantin Osipov
2019-02-06 9:23 ` Vladimir Davydov
2019-02-06 17:04 ` Vladimir Davydov
2019-01-20 21:17 ` [PATCH 7/9] vinyl: randomize range compaction to avoid IO load spikes Vladimir Davydov
2019-01-22 12:54 ` Vladimir Davydov
2019-02-05 17:39 ` [tarantool-patches] " Konstantin Osipov
2019-02-06 8:53 ` Vladimir Davydov
2019-02-06 10:44 ` Konstantin Osipov
2019-02-06 10:52 ` Vladimir Davydov
2019-02-06 11:06 ` Konstantin Osipov
2019-02-06 11:49 ` Vladimir Davydov
2019-02-06 13:43 ` Konstantin Osipov
2019-02-06 14:00 ` Vladimir Davydov
2019-02-05 17:14 ` Konstantin Osipov
2019-01-20 21:17 ` [PATCH 8/9] vinyl: introduce quota consumer types Vladimir Davydov
2019-01-20 21:17 ` [PATCH 9/9] vinyl: throttle tx to ensure compaction keeps up with dumps Vladimir Davydov
2019-01-21 14:14 ` Vladimir Davydov
2019-01-22 9:09 ` 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=82a8ad14d24a705ca9e92176c27c9b072fb6a5b1.1548017258.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 4/9] vinyl: rename lsm->range_heap to max_compaction_priority' \
/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