From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: [tarantool-patches] [PATCH 05/12] vinyl: do not reallocate tuple formats on alter From: "v.shpilevoy@tarantool.org" In-Reply-To: <475ebc439ee72ccd55b1158c354a01b2452a6bd5.1522572161.git.vdavydov.dev@gmail.com> Date: Sun, 1 Apr 2018 14:12:26 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <998CF4CA-7826-4848-B895-C82D8C8DDB22@tarantool.org> References: <475ebc439ee72ccd55b1158c354a01b2452a6bd5.1522572161.git.vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Cc: Konstantin Osipov , Vladimir Davydov List-ID: > 1 =D0=B0=D0=BF=D1=80. 2018 =D0=B3., =D0=B2 12:05, Vladimir Davydov = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0= ): >=20 > We create new formats for all indexes of the new space in > vinyl_space_commit_alter() while we don't actually need to > do this, because the new formats have already been created > by vy_lsm_new() - all we need to do is reuse them somehow. >=20 > This patch does the trick: it implements the swap_index() > space virtual method for vinyl so that it swaps tuple formats > between the old and new spaces. > --- > src/box/vinyl.c | 58 = ++++++++++++++++++++++----------------------------------- > 1 file changed, 22 insertions(+), 36 deletions(-) >=20 > 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 =3D = vy_lsm(old_space->index_map[old_index_id]); > + struct vy_lsm *new_lsm =3D = 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. > + 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); > } >=20 > static int > @@ -3938,7 +3924,7 @@ static const struct space_vtab vinyl_space_vtab = =3D { > /* .drop_primary_key =3D */ vinyl_space_drop_primary_key, > /* .check_format =3D */ vinyl_space_check_format, > /* .build_secondary_key =3D */ vinyl_space_build_secondary_key, > - /* .swap_index =3D */ generic_space_swap_index, > + /* .swap_index =3D */ vinyl_space_swap_index, > /* .prepare_alter =3D */ vinyl_space_prepare_alter, > /* .commit_alter =3D */ vinyl_space_commit_alter, > }; > --=20 > 2.11.0 >=20 >=20