From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 1 Apr 2018 14:24:18 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] [PATCH 05/12] vinyl: do not reallocate tuple formats on alter Message-ID: <20180401112418.gcfo7soj2flmv4mg@esperanza> References: <475ebc439ee72ccd55b1158c354a01b2452a6bd5.1522572161.git.vdavydov.dev@gmail.com> <998CF4CA-7826-4848-B895-C82D8C8DDB22@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <998CF4CA-7826-4848-B895-C82D8C8DDB22@tarantool.org> To: "v.shpilevoy@tarantool.org" Cc: tarantool-patches@freelists.org, Konstantin Osipov List-ID: On Sun, Apr 01, 2018 at 02:12:26PM +0300, v.shpilevoy@tarantool.org wrote: > > diff --git a/src/box/vinyl.c b/src/box/vinyl.c > > index fc37283a..f3cef52f 100644 > > --- a/src/box/vinyl.c > > +++ b/src/box/vinyl.c > > +static void > > +vinyl_space_swap_index(struct space *old_space, struct space *new_space, > > + uint32_t old_index_id, uint32_t new_index_id) > > +{ > > + struct vy_lsm *old_lsm = vy_lsm(old_space->index_map[old_index_id]); > > + struct vy_lsm *new_lsm = vy_lsm(new_space->index_map[new_index_id]); > > + > > + /* > > + * Swap the two indexes between the two spaces, > > + * but leave tuple formats. > > + */ > > + generic_space_swap_index(old_space, new_space, > > + old_index_id, new_index_id); > > + > > + SWAP(old_lsm->mem_format, new_lsm->mem_format); > > How do you swap the formats, if they are variable length structures? > 1) Their fields[] arrays are not swapped here, 2) even if you will try > to swap - they can have different length. I swap pointers, not objects: struct vy_lsm { ... struct tuple_format *disk_format; struct tuple_format *mem_format; struct tuple_format *mem_format_with_colmask; }; > > > + SWAP(old_lsm->mem_format_with_colmask, > > + new_lsm->mem_format_with_colmask); > > + SWAP(old_lsm->disk_format, new_lsm->disk_format); > > + SWAP(old_lsm->opts, new_lsm->opts); > > }