[tarantool-patches] Re: [PATCH 08/12] vinyl: remove optimized comparators

Konstantin Osipov kostja at tarantool.org
Thu Feb 21 14:11:33 MSK 2019

* Vladimir Davydov <vdavydov.dev at gmail.com> [19/02/21 13:31]:
> A vinyl statement (vy_stmt struct) may represent either a tuple or a
> key. We differentiate between the two kinds by statement type - we use
> SELECT for keys and other types for tuples. This was done that way so
> that we could pass both tuples and keys to a read iterator as a search
> key. To avoid branching in comparators when the types of compared
> statements are known in advance, we provide several comparators, each of
> which expects certain statement types, e.g. a tuple and a key. Actually,
> such a micro optimization looks like an overkill, because a typical
> comparator is called by a function pointer and has a lot of comparisons
> in the code, see tuple_compare_slowpath for instance. Eliminating one
> branch will hardly make the code perform better. At the same time, it
> makes the code more difficult to write. Besides, once we remove nils
> from statements read from disk (aka surrogate tuples), which is required
> to support multikey index, the number of places where types of compared
> statements are known will diminish drastically. That said, let's remove
> optimized comparators and always use vy_stmt_compare, which checks types
> of compared statements and calls the appropriate comparator.

This is OK to push, but please don't push it until it's really
needed (e.g. until you get OK to push on a patch which uses it).

Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

More information about the Tarantool-patches mailing list