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 AC20828DEF for ; Wed, 15 Aug 2018 08:14:49 -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 gmJBj8gUJ_aZ for ; Wed, 15 Aug 2018 08:14:49 -0400 (EDT) Received: from smtp20.mail.ru (smtp20.mail.ru [94.100.179.251]) (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 655C228BF0 for ; Wed, 15 Aug 2018 08:14:49 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 2/5] box: introduce slot_cache in key_part References: <14a46618ad51e12394c1f578adbd8874b49ce93c.1533558332.git.kshcherbatov@tarantool.org> From: Kirill Shcherbatov Message-ID: Date: Wed, 15 Aug 2018 15:14:47 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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, Vladislav Shpilevoy >> - const struct key_part *part = key_def->parts; >> + struct key_part *part = (struct key_part *)key_def->parts; > 1. Why? Fixed. > 2. These things were needed to get formats and tuples data once. Now you > lookup format and raw data on each part in the cycle below. So it is > slower in part_count times. See below the main comment. > 3. As I said you verbally, when we were discussing how to implement > comparators, you do not need to use slot cache, epochs and other > complex JSON things to compare flat index keys, with no JSON paths. You > should add a new template parameter to tuple_compare_slowpath like > 'is_flat' or something, and if it is false, then use regular tuple_field > or tuple_field_raw. If true, then try to use slot cache, epoch etc. > Comparators are chosen once when key_def is created and template 'if' > is compile time, so these 'if's will cost nothing. > > Now tuple_field_by_part is much slower than tuple_field_raw - it makes > additional lookup of a format (from a huge array of tuple formats), > of tuple data (additional call), field map (one more call). Further > both tuple_field_by_part and tuple_field_raw do 3 'if's and lookup > in field_map. But tuple_field_raw also updates slot_cache and > format_epoch - it is +2 assignments. So tuple_field_raw is faster. > In this cycle in the summary it is in part_count times faster. > > So please, do not use tuple_field_by_part for flat indexes. It has no > profit for them. > > All the same about key extraction and hash. Done as you've suggested. > 4. Tuple format should not depend on tuple. Vice versa. Please, > consult other tuple_field methods how to solve this dependency > cycle. There is no such problem already. > 5. Looks like you've ignored my point that a global format > epoch will expire epoch in all formats when just a one > space is altered. Please, do not. Epoch should be one per > space. I've introduced new function space_format_update_epoch that is called on alter. > 6. Prefix flags with 'is_'. Ok, fixed. > 7. Why do you need it? I've reeworked this function a lot as a part of following patch. Here is wrapper that calls tuple_field_raw now in this patch. > 8. Too small comment for such complex feature. I've wrote a bigger comment.