From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: tarantool-patches@freelists.org Subject: [PATCH 06/12] vinyl: refine vy_history_cleanup Date: Sun, 15 Apr 2018 22:55:19 +0300 [thread overview] Message-ID: <59fefe828becd85d64c53bd306d27005fcaa2483.1523820298.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1523820298.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1523820298.git.vdavydov.dev@gmail.com> - Remove region_truncate from vy_history_cleanup. There may be other objects apart from vy_history_node allocated on the region so it is conceptually wrong to free memory in vy_history_cleanup. - Reinitialize the history list in vy_history_cleanup so that it isn't incumbent on the caller to call vy_history_create to reuse a history after cleanup. This will simplify usage of vy_history in the read iterator. --- src/box/vy_point_lookup.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/box/vy_point_lookup.c b/src/box/vy_point_lookup.c index f932f07f..7c9995ed 100644 --- a/src/box/vy_point_lookup.c +++ b/src/box/vy_point_lookup.c @@ -110,17 +110,17 @@ vy_history_append_stmt(struct vy_history *history, struct tuple *stmt) } /** - * Unref statement if necessary, remove node from history if it's there. + * Release all statements stored in the given history and + * reinitialize the history list. */ static void -vy_history_cleanup(struct vy_history *history, size_t region_svp) +vy_history_cleanup(struct vy_history *history) { struct vy_history_node *node; rlist_foreach_entry(node, &history->stmts, link) if (node->is_refable) tuple_unref(node->stmt); - - region_truncate(&fiber()->gc, region_svp); + rlist_create(&history->stmts); } /** @@ -384,9 +384,8 @@ vy_point_lookup(struct vy_lsm *lsm, struct vy_tx *tx, lsm->stat.lookup++; /* History list */ struct vy_history history; -restart: vy_history_create(&history); - +restart: rc = vy_point_lookup_scan_txw(lsm, tx, key, &history); if (rc != 0 || vy_history_is_terminal(&history)) goto done; @@ -421,7 +420,8 @@ restart: * This in unnecessary in case of rotation but since we * cannot distinguish these two cases we always restart. */ - vy_history_cleanup(&history, region_svp); + vy_history_cleanup(&history); + region_truncate(&fiber()->gc, region_svp); goto restart; } @@ -432,7 +432,8 @@ done: &upserts_applied, ret); lsm->stat.upsert.applied += upserts_applied; } - vy_history_cleanup(&history, region_svp); + vy_history_cleanup(&history); + region_truncate(&fiber()->gc, region_svp); if (rc != 0) return -1; -- 2.11.0
next prev parent reply other threads:[~2018-04-15 19:55 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-04-15 19:55 [PATCH 00/12] vinyl: prepare read iterator for index rebuild Vladimir Davydov 2018-04-15 19:55 ` [PATCH 01/12] vinyl: rename vy_stmt_history to vy_history Vladimir Davydov 2018-04-15 19:55 ` [PATCH 02/12] vinyl: factor out vy_history_apply from vy_point_lookup_apply_history Vladimir Davydov 2018-05-14 18:19 ` [tarantool-patches] " Vladislav Shpilevoy 2018-04-15 19:55 ` [PATCH 03/12] vinyl: add vy_history_append_stmt helper Vladimir Davydov 2018-04-15 19:55 ` [PATCH 04/12] vinyl: zap iterator_src_type enum Vladimir Davydov 2018-04-15 19:55 ` [PATCH 05/12] vinyl: encapsulate key history with struct Vladimir Davydov 2018-04-15 19:55 ` Vladimir Davydov [this message] 2018-04-15 19:55 ` [PATCH 07/12] vinyl: move vy_history to its own source file Vladimir Davydov 2018-04-15 19:55 ` [PATCH 08/12] vinyl: use mempool for vy_history_node allocations Vladimir Davydov 2018-04-15 19:55 ` [PATCH 09/12] vinyl: consolidate skip optimization checks in read iterator Vladimir Davydov 2018-05-14 18:25 ` [tarantool-patches] " Vladislav Shpilevoy 2018-05-15 15:00 ` Vladimir Davydov 2018-04-15 19:55 ` [PATCH 10/12] vinyl: refactor vy_read_iterator_next Vladimir Davydov 2018-04-15 19:55 ` [PATCH 11/12] vinyl: make read iterator always return newest tuple version Vladimir Davydov 2018-04-15 19:55 ` [PATCH 12/12] vinyl: zap vy_read_iterator::curr_stmt Vladimir Davydov 2018-05-04 18:05 ` [tarantool-patches] Re: [PATCH 00/12] vinyl: prepare read iterator for index rebuild Vladislav Shpilevoy
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=59fefe828becd85d64c53bd306d27005fcaa2483.1523820298.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 06/12] vinyl: refine vy_history_cleanup' \ /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