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 C02A325063 for ; Fri, 11 May 2018 10:39:57 -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 nZFg4FeSxnbr for ; Fri, 11 May 2018 10:39:57 -0400 (EDT) Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (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 12C5B25067 for ; Fri, 11 May 2018 10:39:56 -0400 (EDT) Date: Fri, 11 May 2018 17:39:54 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [commits] [tarantool] 02/05: collation: introduce collation fingerprint Message-ID: <20180511143954.GA9715@atlas> References: <152598686117.24855.10393970012441684689@localhost> <1525986347.906931598.25688049591563982@mxpdd5.i.mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1525986347.906931598.25688049591563982@mxpdd5.i.mail.ru> 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: Vladislav Shpilevoy Cc: tarantool-patches@freelists.org * Vladislav Shpilevoy [18/05/11 02:00]: > This is an automated email from the git hooks/post-receive script. > > Gerold103 pushed a commit to branch gh-3290-lua-icu > in repository tarantool. > > commit 2fb226b2b5c01a42565294abc59a9171d5f695fe > Author: Vladislav Shpilevoy > AuthorDate: Tue May 8 21:48:18 2018 +0300 > > collation: introduce collation fingerprint > > Collation fingerprint is a formatted string unique for a set > of collation properties. Equal collations with different names > have the same fingerprint. > > This new property is used to build collation fingerprint cache > to use in Tarantool internals, where collation name does not > matter. > > Fingerprint cache can never conflict or replace on insertion into > it. It means, that, for example, utf8 module being created in > this patchset, can fill collation cache with its own collations > and it will affect neither users or other modules. > --- > src/box/alter.cc | 8 ++-- > src/box/coll.c | 21 ++++++++- > src/box/coll.h | 19 +++++++++ > src/box/coll_cache.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++---- > src/box/coll_cache.h | 4 +- > src/box/coll_def.c | 36 ++++++++++++++++ > src/box/coll_def.h | 19 +++++++++ > 7 files changed, 209 insertions(+), 16 deletions(-) > > diff --git a/src/box/alter.cc b/src/box/alter.cc > index de8ccd3..9ca759c 100644 > --- a/src/box/alter.cc > +++ b/src/box/alter.cc > @@ -2386,7 +2386,7 @@ coll_cache_rollback(struct trigger *trigger, void *event) > return; > } > struct coll *replaced; > - if (coll_cache_replace(old_coll, &replaced) != 0) { > + if (coll_cache_id_replace(old_coll, &replaced) != 0) { > panic("Out of memory on insertion into collation "\ The name has become unclear now. > - size_t total_len = sizeof(struct coll) + def->name_len + 1; > - struct coll *coll = (struct coll *)calloc(1, total_len); > + int fingerprint_offset = sizeof(struct coll) + def->name_len + 1; > + int fingerprint_len = coll_def_fingerprint_len(def); You don't need a separate member for fingerprint length, asciiz string is fine. > +uint32_t > +coll_fingerprint_hash(const char *fingerprint, int len) > +{ > + uint32_t h = 13; > + uint32_t carry = 0; > + PMurHash32_Process(&h, &carry, fingerprint, len); > + return PMurHash32_Result(h, carry, len); > +} > +struct mh_coll_node_t { > + /** > + * Collation with unique fingerprint in the collation > + * cache. > + */ > + struct coll *coll; > + /** > + * Reference counter. How many collations has the same > + * fingerprint. This node is deleted from the cache only > + * when there are no more collations with the same > + * fingerprint. > + */ > + int refs; > +}; Please rewrite the code without double level of reference counting. -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov