From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 6/7] vinyl: zap vy_mem::min_lsn and rename max_lsn to dump_lsn
Date: Tue, 21 Aug 2018 14:15:39 +0300 [thread overview]
Message-ID: <a5023cbcf8e0cc72b033fb86ee58b6751c145961.1534847663.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1534847663.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1534847663.git.vdavydov.dev@gmail.com>
We never use vy_mem::min_lsn so let's zap it. As for max_lsn, we only
need it to update vy_lsm::dump_lsn (max LSN stored on disk). Let's
rename it appropriately. There's another reason to do that. Once we
start storing deferred DELETE statements in memory (see #2129), it won't
be the max statement LSN stored in vy_mem anymore, because we will
account WAL LSN of deferred DELETE statements there too. Renaming it to
dump_lsn will help avoid confusion.
Needed for #2129
---
src/box/vy_mem.c | 8 +++-----
src/box/vy_mem.h | 10 +++++++---
src/box/vy_scheduler.c | 2 +-
test/unit/vy_mem.c | 11 ++++-------
test/unit/vy_mem.result | 22 ++++++++++------------
5 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/src/box/vy_mem.c b/src/box/vy_mem.c
index 0c46b93c..f9be8505 100644
--- a/src/box/vy_mem.c
+++ b/src/box/vy_mem.c
@@ -108,8 +108,7 @@ vy_mem_new(struct vy_mem_env *env, int64_t generation,
return NULL;
}
index->env = env;
- index->min_lsn = INT64_MAX;
- index->max_lsn = -1;
+ index->dump_lsn = -1;
index->cmp_def = cmp_def;
index->generation = generation;
index->space_cache_version = space_cache_version;
@@ -249,11 +248,10 @@ vy_mem_commit_stmt(struct vy_mem *mem, const struct tuple *stmt)
/*
* Normally statement LSN grows monotonically,
* but not in case of building an index on an
- * existing non-empty space. Hence use of MIN/MAX
+ * existing non-empty space. Hence use of MAX
* here.
*/
- mem->min_lsn = MIN(mem->min_lsn, lsn);
- mem->max_lsn = MAX(mem->max_lsn, lsn);
+ mem->dump_lsn = MAX(mem->dump_lsn, lsn);
/*
* If we don't bump mem version after assigning LSN to
* a mem statement, a read iterator which uses
diff --git a/src/box/vy_mem.h b/src/box/vy_mem.h
index 52caa316..957f549f 100644
--- a/src/box/vy_mem.h
+++ b/src/box/vy_mem.h
@@ -166,9 +166,13 @@ struct vy_mem {
size_t tree_extent_size;
/** Number of statements. */
struct vy_stmt_counter count;
- /** The min and max values of stmt->lsn in this tree. */
- int64_t min_lsn;
- int64_t max_lsn;
+ /**
+ * Max LSN covered by this in-memory tree.
+ *
+ * Once the tree is dumped to disk it will be used to update
+ * vy_lsm::dump_lsn, see vy_task_dump_new().
+ */
+ int64_t dump_lsn;
/**
* Key definition for this index, extended with primary
* key parts.
diff --git a/src/box/vy_scheduler.c b/src/box/vy_scheduler.c
index 4e8b476b..7d8961c4 100644
--- a/src/box/vy_scheduler.c
+++ b/src/box/vy_scheduler.c
@@ -982,7 +982,7 @@ vy_task_dump_new(struct vy_scheduler *scheduler, struct vy_lsm *lsm,
vy_lsm_delete_mem(lsm, mem);
continue;
}
- dump_lsn = MAX(dump_lsn, mem->max_lsn);
+ dump_lsn = MAX(dump_lsn, mem->dump_lsn);
}
if (dump_lsn < 0) {
diff --git a/test/unit/vy_mem.c b/test/unit/vy_mem.c
index 6666f94c..967aabe8 100644
--- a/test/unit/vy_mem.c
+++ b/test/unit/vy_mem.c
@@ -18,21 +18,18 @@ test_basic(void)
assert(key_def != NULL);
struct vy_mem *mem = create_test_mem(key_def);
- is(mem->min_lsn, INT64_MAX, "mem->min_lsn on empty mem");
- is(mem->max_lsn, -1, "mem->max_lsn on empty mem");
+ is(mem->dump_lsn, -1, "mem->dump_lsn on empty mem");
const struct vy_stmt_template stmts[] = {
STMT_TEMPLATE(100, REPLACE, 1), STMT_TEMPLATE(101, REPLACE, 1),
STMT_TEMPLATE(102, REPLACE, 1), STMT_TEMPLATE(103, REPLACE, 1),
STMT_TEMPLATE(104, REPLACE, 1)
};
- /* Check min/max lsn */
+ /* Check dump lsn */
const struct tuple *stmt = vy_mem_insert_template(mem, &stmts[0]);
- is(mem->min_lsn, INT64_MAX, "mem->min_lsn after prepare");
- is(mem->max_lsn, -1, "mem->max_lsn after prepare");
+ is(mem->dump_lsn, -1, "mem->dump_lsn after prepare");
vy_mem_commit_stmt(mem, stmt);
- is(mem->min_lsn, 100, "mem->min_lsn after commit");
- is(mem->max_lsn, 100, "mem->max_lsn after commit");
+ is(mem->dump_lsn, 100, "mem->dump_lsn after commit");
/* Check vy_mem_older_lsn */
const struct tuple *older = stmt;
diff --git a/test/unit/vy_mem.result b/test/unit/vy_mem.result
index 6212173d..5c9c7af5 100644
--- a/test/unit/vy_mem.result
+++ b/test/unit/vy_mem.result
@@ -1,17 +1,15 @@
+# Looks like you planned 12 tests but ran 9.
*** test_basic ***
1..12
-ok 1 - mem->min_lsn on empty mem
-ok 2 - mem->max_lsn on empty mem
-ok 3 - mem->min_lsn after prepare
-ok 4 - mem->max_lsn after prepare
-ok 5 - mem->min_lsn after commit
-ok 6 - mem->max_lsn after commit
-ok 7 - vy_mem_older_lsn 1
-ok 8 - vy_mem_older_lsn 2
-ok 9 - vy_mem_rollback 1
-ok 10 - vy_mem_rollback 2
-ok 11 - vy_mem->version
-ok 12 - vy_mem->version
+ok 1 - mem->dump_lsn on empty mem
+ok 2 - mem->dump_lsn after prepare
+ok 3 - mem->dump_lsn after commit
+ok 4 - vy_mem_older_lsn 1
+ok 5 - vy_mem_older_lsn 2
+ok 6 - vy_mem_rollback 1
+ok 7 - vy_mem_rollback 2
+ok 8 - vy_mem->version
+ok 9 - vy_mem->version
*** test_basic: done ***
*** test_iterator_restore_after_insertion ***
1..1
--
2.11.0
next prev parent reply other threads:[~2018-08-21 11:15 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-21 11:15 [PATCH v2 0/7] vinyl: eliminate disk read on REPLACE/DELETE Vladimir Davydov
2018-08-21 11:15 ` [PATCH v2 1/7] vinyl: do not store meta in secondary index runs Vladimir Davydov
2018-08-21 15:08 ` Konstantin Osipov
2018-08-21 11:15 ` [PATCH v2 2/7] vinyl: teach write iterator to return overwritten tuples Vladimir Davydov
2018-08-21 15:14 ` Konstantin Osipov
2018-08-21 15:37 ` Vladimir Davydov
2018-08-21 11:15 ` [PATCH v2 3/7] vinyl: prepare write iterator heap comparator for deferred DELETEs Vladimir Davydov
2018-08-21 15:38 ` Konstantin Osipov
2018-08-21 11:15 ` [PATCH v2 4/7] vinyl: allow to skip certain statements on read Vladimir Davydov
2018-08-21 15:39 ` Konstantin Osipov
2018-08-21 11:15 ` [PATCH v2 5/7] Introduce _vinyl_deferred_delete system space Vladimir Davydov
2018-08-21 15:42 ` Konstantin Osipov
2018-08-22 17:04 ` Vladimir Davydov
2018-08-21 11:15 ` Vladimir Davydov [this message]
2018-08-21 15:44 ` [PATCH v2 6/7] vinyl: zap vy_mem::min_lsn and rename max_lsn to dump_lsn Konstantin Osipov
2018-08-22 13:00 ` Vladimir Davydov
2018-08-21 11:15 ` [PATCH v2 7/7] vinyl: eliminate disk read on REPLACE/DELETE Vladimir Davydov
2018-08-21 16:13 ` Konstantin Osipov
2018-08-22 17:08 ` Vladimir Davydov
2018-08-22 17:50 ` [PATCH v2 0/7] " 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=a5023cbcf8e0cc72b033fb86ee58b6751c145961.1534847663.git.vdavydov.dev@gmail.com \
--to=vdavydov.dev@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH v2 6/7] vinyl: zap vy_mem::min_lsn and rename max_lsn to dump_lsn' \
/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