Tarantool development patches archive
 help / color / mirror / Atom feed
From: Aleksandr Lyapunov <alyapunov@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH 14/16] tx: indexes
Date: Wed, 15 Jul 2020 13:02:14 +0300	[thread overview]
Message-ID: <811edf37-2708-0c08-6f0c-4acf79b88b8e@tarantool.org> (raw)
In-Reply-To: <bdca882f-880b-aeba-4a76-8356fa709bd4@tarantool.org>

Hi, thanks for your review!

On 15.07.2020 02:50, Vladislav Shpilevoy wrote:
>
> 1. Missing whitespace afrer =.
fixed
>
>>   #endif /* #ifndef OLD_GOOD_BITSET */
>> +		uint32_t iid = iterator->index->def->iid;
>> +		struct txn *txn = in_txn();
>> +		bool is_rw = txn != NULL;
>> +		*ret = txm_tuple_clarify(txn, tuple, iid, 0, is_rw);
> 2. Some of these values you don't need to load in the cycle. They don't
> change.
>
> * in_txn() can be called out of the cycle just once;
> * is_rw can be calculated only once;
> * iid does not change;
> * struct memtx_bitset_index *index does not change;
>
> The same applies to rtree changes.
Actually that is not a problem for modern compilers not to make the
same thing several times.
For example https://godbolt.org/z/9zvnn5
So it's not a performance issue.
I make those variables as aliases for readability.
I could move them out of loop if you insist but I fear that it will 
become less readable.
>
> 3. On the branch I see a 'txm_snapshot_cleanser' structure
> in this file. But not in the email. Can't review it. Why is
> it called 'cleanser' instead of 'cleaner'? What is it doing?
Shame on me, maybe I forgot to add in. In a new version it's there, with 
comments.
btw renamed is as 'cleaner'
> \
>> +	do {                                                                   \
>> +		int rc = first ? name##_base(iterator, ret)                    \
>> +			       : hash_iterator_ge_base(iterator, ret);         \
> 4. Seems like unnecessary branching. If you know you will specially
> handle only the first iteration, then why no to make it before the
> cycle? And eliminate 'first' + '?' branch. Also use prefix 'is_' for
> flag names. Or 'has_'/'does_'/etc. The same for all the other new
> flags, including 'preserve_old_tuple'.
names - ok, but again this work for a compiler https://godbolt.org/z/vbEeEP
I could change it if you insist but compiled code will be merely the same.

>
>> +		if (rc != 0 || *ret == NULL)                                   \
>> +			return rc;                                             \
>> +		first = false;                                                 \
>> +		*ret = txm_tuple_clarify(txn, *ret, iid, 0, is_rw);            \
>> +	} while (*ret == NULL);                                                \
>> +	return 0;                                                              \
>> +}                                                                              \
> 5. Please, use tabs for alignment. In other places too.
done
>
>> +struct forgot_to_add_semicolon
> 6. What is this?
That's a standard guard that prohibits usage of macro w/o semicolon in 
the end of line
If somebody forgets to add ; he will get an error message with 
'forgot_to_add_semicolon'.
>
>> +
>> 7. Why did you remove the hash_iterator_ge() call? You still can use
>> it here, with the new name hash_iterator_ge_base().
fixed
>
>> +	bool is_rw = txn != NULL;
>> +	*ret = txm_tuple_clarify(txn, *res, ptr->index->def->iid, 0, is_rw);
> 8. Why isn't it a cycle?
because there can be only one tuple with the desired key in the hash table.
>
> 9. Why 'txn != NULL' can't be done inside txm_tuple_clarify()? It
> takes txn pointer anyway, and you calculate 'is_rw' everywhere
> before the call.
Historical, will fix it.
>
>> +	return 0;
>>   }
>>   
>> +
> 10. Unnecessary new line.
ok
>
>> +	struct memtx_tree_iterator *ti = &it->tree_iterator;                   \
>> +	uint32_t iid = iterator->index->def->iid;                              \
>> +	bool is_multikey = iterator->index->def->key_def->is_multikey;         \
> 11. All these dereferences are going to cost a lot, even when
> there are no concurrent txns. Can they be done in a lazy mode?
> Only if the found tuple is dirty. The same applies to all the
> other places.
A compiler should surely handle it, since ..._clarify() is a static 
inline member.
Even a processor would handle it, it also reorders instructions, but usually
it has nothing to do while the tuple is fetching from memory, and I guess
it will try to do something even outside a branch.

  reply	other threads:[~2020-07-15 10:02 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-08 15:14 [Tarantool-patches] [PATCH v2 00/16] Transaction engine for memtx engine Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 01/16] Update license file (2020) Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 02/16] Check data_offset overflow in struct tuple Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-14 17:09     ` Aleksandr Lyapunov
2020-07-14 22:48       ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 03/16] tx: introduce dirty tuples Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-12 22:24     ` Nikita Pettik
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 04/16] vinyl: rename tx_manager -> vy_tx_manager Aleksandr Lyapunov
2020-07-12 17:14   ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 05/16] tx: save txn in txn_stmt Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 06/16] tx: add TX status Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 07/16] tx: save preserve old tuple flag in txn_stmt Aleksandr Lyapunov
2020-07-12 17:14   ` Vladislav Shpilevoy
2020-07-14 23:46   ` Vladislav Shpilevoy
2020-07-15  7:53     ` Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 08/16] tx: introduce tx manager Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 09/16] tx: introduce prepare sequence number Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 10/16] tx: introduce txn_stmt_destroy Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 11/16] tx: introduce conflict tracker Aleksandr Lyapunov
2020-07-12 17:15   ` Vladislav Shpilevoy
2020-07-14 23:51   ` Vladislav Shpilevoy
2020-07-15  7:57     ` Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 12/16] introduce tuple smart pointers Aleksandr Lyapunov
2020-07-12 17:16   ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 13/16] tx: introduce txm_story Aleksandr Lyapunov
2020-07-12 17:14   ` Vladislav Shpilevoy
2020-07-14 23:46   ` Vladislav Shpilevoy
2020-07-15  8:11     ` Aleksandr Lyapunov
2020-07-15 22:02       ` Vladislav Shpilevoy
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 14/16] tx: indexes Aleksandr Lyapunov
2020-07-14 23:50   ` Vladislav Shpilevoy
2020-07-15 10:02     ` Aleksandr Lyapunov [this message]
2020-07-15 22:08       ` Vladislav Shpilevoy
2020-07-15 10:19     ` Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 15/16] tx: introduce point conflict tracker Aleksandr Lyapunov
2020-07-08 15:14 ` [Tarantool-patches] [PATCH 16/16] tx: use new tx manager in memtx Aleksandr Lyapunov
2020-07-14 23:45   ` Vladislav Shpilevoy
2020-07-15 10:32     ` Aleksandr Lyapunov
2020-07-15 22:09       ` Vladislav Shpilevoy
2020-07-12 17:19 ` [Tarantool-patches] [PATCH v2 00/16] Transaction engine for memtx engine Vladislav Shpilevoy
2020-07-14 23:47 ` Vladislav Shpilevoy
2020-07-15 12:25   ` Aleksandr Lyapunov
2020-07-15 22:10     ` Vladislav Shpilevoy
2020-07-16  4:48       ` Aleksandr Lyapunov

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=811edf37-2708-0c08-6f0c-4acf79b88b8e@tarantool.org \
    --to=alyapunov@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 14/16] tx: indexes' \
    /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