From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 90E902CCB6 for ; Fri, 19 Apr 2019 08:44:11 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PZdlliZLTxPU for ; Fri, 19 Apr 2019 08:44:11 -0400 (EDT) Received: from smtp50.i.mail.ru (smtp50.i.mail.ru [94.100.177.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id BAE952CCAF for ; Fri, 19 Apr 2019 08:44:10 -0400 (EDT) From: Georgy Kirichenko Subject: [tarantool-patches] [PATCH 02/10] Alloc journal entry on a txn memory region Date: Fri, 19 Apr 2019 15:43:58 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Georgy Kirichenko 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