Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH v2 13/14] vinyl: don't use vy_stmt_new_surrogate_delete if not necessary
Date: Wed, 13 Mar 2019 11:52:59 +0300	[thread overview]
Message-ID: <9fc6bd59f685ae46394f8cf2c692bc3641489e20.1552464666.git.vdavydov.dev@gmail.com> (raw)
In-Reply-To: <cover.1552464666.git.vdavydov.dev@gmail.com>
In-Reply-To: <cover.1552464666.git.vdavydov.dev@gmail.com>

There are three places where we use this expensive functions while we
could get along with a cheaper one:

 - Deferred DELETE space on_replace trigger. Here we can use simple
   vy_stmt_new_delete, because the trigger is already passed a surrogate
   DELETE statement.

 - Secondary index build on_replace trigger. Here we can extract the
   secondary key, set its type to DELETE and insert it into the index.
   We don't need all the other indexed fields.

 - Secondary index build recovery procedure. Similarly to the previous
   case, we can use extracted here rather than building a surrogate
   DELETE statement.
---
 src/box/vinyl.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index f2d9ab55..80296269 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -3935,10 +3935,11 @@ vy_build_on_replace(struct trigger *trigger, void *event)
 
 	/* Forward the statement to the new LSM tree. */
 	if (stmt->old_tuple != NULL) {
-		struct tuple *delete = vy_stmt_new_surrogate_delete(format,
-							stmt->old_tuple);
+		struct tuple *delete = vy_stmt_extract_key(stmt->old_tuple,
+					lsm->cmp_def, lsm->env->key_format);
 		if (delete == NULL)
 			goto err;
+		vy_stmt_set_type(delete, IPROTO_DELETE);
 		int rc = vy_tx_set(tx, lsm, delete);
 		tuple_unref(delete);
 		if (rc != 0)
@@ -4076,10 +4077,11 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk,
 	struct tuple *delete = NULL;
 	struct tuple *insert = NULL;
 	if (old_tuple != NULL) {
-		delete = vy_stmt_new_surrogate_delete(lsm->mem_format,
-						      old_tuple);
+		delete = vy_stmt_extract_key(old_tuple, lsm->cmp_def,
+					     lsm->env->key_format);
 		if (delete == NULL)
 			return -1;
+		vy_stmt_set_type(delete, IPROTO_DELETE);
 	}
 	enum iproto_type type = vy_stmt_type(mem_stmt);
 	if (type == IPROTO_REPLACE || type == IPROTO_INSERT) {
@@ -4387,8 +4389,8 @@ vy_deferred_delete_on_replace(struct trigger *trigger, void *event)
 
 	/* Create the deferred DELETE statement. */
 	struct vy_lsm *pk = vy_lsm(space->index[0]);
-	struct tuple *delete = vy_stmt_new_surrogate_delete_raw(pk->mem_format,
-						delete_data, delete_data_end);
+	struct tuple *delete = vy_stmt_new_delete(pk->mem_format, delete_data,
+						  delete_data_end);
 	if (delete == NULL)
 		diag_raise();
 	/*
-- 
2.11.0

  parent reply	other threads:[~2019-03-13  8:52 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13  8:52 [PATCH v2 00/14] vinyl: do not fill secondary tuples with nulls Vladimir Davydov
2019-03-13  8:52 ` [PATCH v2 01/14] vinyl: remove optimized comparators Vladimir Davydov
2019-03-13  8:55   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 02/14] vinyl: introduce statement environment Vladimir Davydov
2019-03-13  8:58   ` Konstantin Osipov
2019-03-13  9:19     ` Vladimir Davydov
2019-03-13  8:52 ` [PATCH v2 03/14] vinyl: rename key stmt construction routine Vladimir Davydov
2019-03-13  8:59   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 04/14] vinyl: don't use IPROTO_SELECT type for key statements Vladimir Davydov
2019-03-13  9:00   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 05/14] bloom: do not use tuple_common_key_parts when constructing tuple bloom Vladimir Davydov
2019-03-13 11:52   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 06/14] bloom: factor out helper to add tuple hash to bloom builder Vladimir Davydov
2019-03-13 11:52   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 07/14] vinyl: add helpers to add/check statement with bloom Vladimir Davydov
2019-03-13 11:59   ` Konstantin Osipov
2019-03-13 12:25     ` Vladimir Davydov
2019-03-13  8:52 ` [PATCH v2 08/14] vinyl: do not pass format to vy_apply_upsert Vladimir Davydov
2019-03-13 12:00   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 09/14] vinyl: clean up write iterator source destruction Vladimir Davydov
2019-03-13 12:05   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 10/14] vinyl: zap vy_write_iterator->format Vladimir Davydov
2019-03-13 12:06   ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 11/14] vinyl: do not fill secondary tuples with nulls when decoded Vladimir Davydov
2019-03-13 12:25   ` Konstantin Osipov
2019-03-13 12:45     ` Vladimir Davydov
2019-03-13 12:56       ` Konstantin Osipov
2019-03-13  8:52 ` [PATCH v2 12/14] vinyl: zap vy_stmt_new_surrogate_from_key Vladimir Davydov
2019-03-13 12:27   ` Konstantin Osipov
2019-03-13  8:52 ` Vladimir Davydov [this message]
2019-03-13 12:28   ` [PATCH v2 13/14] vinyl: don't use vy_stmt_new_surrogate_delete if not necessary Konstantin Osipov
2019-03-13  8:53 ` [PATCH v2 14/14] tuple_format: zap min_tuple_size Vladimir Davydov
2019-03-13 12:28   ` Konstantin Osipov
2019-03-13 15:54 ` [PATCH v2 00/14] vinyl: do not fill secondary tuples with nulls 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=9fc6bd59f685ae46394f8cf2c692bc3641489e20.1552464666.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 13/14] vinyl: don'\''t use vy_stmt_new_surrogate_delete if not necessary' \
    /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