Tarantool development patches archive
 help / color / mirror / Atom feed
From: Georgy Kirichenko <georgy@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Georgy Kirichenko <georgy@tarantool.org>
Subject: [tarantool-patches] [PATCH 02/10] Alloc journal entry on a txn memory region
Date: Fri, 19 Apr 2019 15:43:58 +0300	[thread overview]
Message-ID: <fd6aea5b647fab8f2994d692f6d8ee3ee316123f.1555677159.git.georgy@tarantool.org> (raw)
In-Reply-To: <cover.1555677159.git.georgy@tarantool.org>

Use txn memory to allocate a journal entry structure.
This relaxes a dependency between a journal entry and a fiber.

Prerequisites: #1254
---
 src/box/journal.c | 4 ++--
 src/box/journal.h | 4 +++-
 src/box/txn.c     | 3 ++-
 src/box/vy_log.c  | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/box/journal.c b/src/box/journal.c
index 7498ba192..fe13fb6ee 100644
--- a/src/box/journal.c
+++ b/src/box/journal.c
@@ -53,14 +53,14 @@ static struct journal dummy_journal = {
 struct journal *current_journal = &dummy_journal;
 
 struct journal_entry *
-journal_entry_new(size_t n_rows)
+journal_entry_new(size_t n_rows, struct region *region)
 {
 	struct journal_entry *entry;
 
 	size_t size = (sizeof(struct journal_entry) +
 		       sizeof(entry->rows[0]) * n_rows);
 
-	entry = region_aligned_alloc(&fiber()->gc, size,
+	entry = region_aligned_alloc(region, size,
 				     alignof(struct journal_entry));
 	if (entry == NULL) {
 		diag_set(OutOfMemory, size, "region", "struct journal_entry");
diff --git a/src/box/journal.h b/src/box/journal.h
index e52316888..8ac32ee5e 100644
--- a/src/box/journal.h
+++ b/src/box/journal.h
@@ -72,13 +72,15 @@ struct journal_entry {
 	struct xrow_header *rows[];
 };
 
+struct region;
+
 /**
  * Create a new journal entry.
  *
  * @return NULL if out of memory, fiber diagnostics area is set
  */
 struct journal_entry *
-journal_entry_new(size_t n_rows);
+journal_entry_new(size_t n_rows, struct region *region);
 
 /**
  * An API for an abstract journal for all transactions of this
diff --git a/src/box/txn.c b/src/box/txn.c
index 815199645..ed5e54bb6 100644
--- a/src/box/txn.c
+++ b/src/box/txn.c
@@ -332,7 +332,8 @@ txn_write_to_wal(struct txn *txn)
 	assert(txn->n_new_rows + txn->n_applier_rows > 0);
 
 	struct journal_entry *req = journal_entry_new(txn->n_new_rows +
-						      txn->n_applier_rows);
+						      txn->n_applier_rows,
+						      &txn->region);
 	if (req == NULL)
 		return -1;
 
diff --git a/src/box/vy_log.c b/src/box/vy_log.c
index be97cdbbe..85059588e 100644
--- a/src/box/vy_log.c
+++ b/src/box/vy_log.c
@@ -772,7 +772,7 @@ vy_log_flush(void)
 		tx_size++;
 
 	size_t used = region_used(&fiber()->gc);
-	struct journal_entry *entry = journal_entry_new(tx_size);
+	struct journal_entry *entry = journal_entry_new(tx_size, &fiber()->gc);
 	if (entry == NULL)
 		goto err;
 
-- 
2.21.0

  parent reply	other threads:[~2019-04-19 12:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19 12:43 [tarantool-patches] [PATCH 00/10] Transaction refactoring Georgy Kirichenko
2019-04-19 12:43 ` [tarantool-patches] [PATCH 01/10] Introduce a txn memory region Georgy Kirichenko
2019-04-24 18:20   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:43 ` Georgy Kirichenko [this message]
2019-04-24 18:21   ` [tarantool-patches] Re: [PATCH 02/10] Alloc journal entry on " Konstantin Osipov
2019-04-19 12:43 ` [tarantool-patches] [PATCH 03/10] Encode a dml statement to a transaction " Georgy Kirichenko
2019-04-24 18:28   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 04/10] Get rid of autocommit from a txn structure Georgy Kirichenko
2019-04-24 19:07   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 05/10] Get rid of fiber_gc from txn_rollback Georgy Kirichenko
2019-04-24 19:12   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 06/10] Require for txn in case of txn_begin_stmt/txn_rollback_stmt Georgy Kirichenko
2019-04-24 19:13   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 07/10] Remove fiber from a journal_entry structure Georgy Kirichenko
2019-04-24 19:16   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 08/10] Use mempool to alloc wal messages Georgy Kirichenko
2019-04-24 19:18   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 09/10] Enable asyncronous wal writes Georgy Kirichenko
2019-04-24 19:19   ` [tarantool-patches] " Konstantin Osipov
2019-04-19 12:44 ` [tarantool-patches] [PATCH 10/10] Introduce asynchronous txn commit Georgy Kirichenko
2019-04-24 19:20   ` [tarantool-patches] " 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=fd6aea5b647fab8f2994d692f6d8ee3ee316123f.1555677159.git.georgy@tarantool.org \
    --to=georgy@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH 02/10] Alloc journal entry on a txn memory region' \
    /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