From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 22 Jan 2019 12:17:16 +0300 From: Vladimir Davydov Subject: Re: [PATCH 6/9] vinyl: set range size automatically Message-ID: <20190122091716.enjpg7spti7xoic2@esperanza> References: <6cd378d1640f87d46a6e40f1c51e4ae62a70c209.1548017258.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6cd378d1640f87d46a6e40f1c51e4ae62a70c209.1548017258.git.vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org List-ID: On Mon, Jan 21, 2019 at 12:17:05AM +0300, Vladimir Davydov wrote: > +int64_t > +vy_lsm_range_size(struct vy_lsm *lsm) > +{ > + /* Use the configured range size if available. */ > + if (lsm->opts.range_size > 0) > + return lsm->opts.range_size; > + /* > + * It doesn't make much sense to create too small ranges. > + * Limit the max number of ranges per index to 1000 and > + * never create ranges smaller than 16 MB. > + */ > + enum { MIN_RANGE_SIZE = 16 * 1024 * 1024 }; > + enum { MAX_RANGE_COUNT = 1000 }; > + /* > + * Ideally, we want to compact roughly the same amount of > + * data after each dump so as to avoid IO bursts caused by > + * simultaneous major compaction of a bunch of ranges, > + * because such IO bursts can lead to a deviation of the > + * LSM tree from the configured shape and, as a result, > + * increased read amplification. To achieve that, we need > + * to have at least as many ranges as the number of dumps > + * it takes to trigger major compaction in a range. > + */ > + int range_count = vy_lsm_dumps_per_compaction(lsm); After having pondered this for a while, I'm inclined to think it isn't such a good idea to use dumps_per_compaction for range_count: first, it won't work for time series like workloads - the range_count won't scale as the space size grows; second, after forcing compaction with index.compact(), the dumps_per_compaction may collapse resulting in massing range coalescing. May be, we'd better use LSM tree fanout for the target number of ranges? But how do we calculate it reliably? > + range_count = MIN(range_count, MAX_RANGE_COUNT); > + int64_t range_size = lsm->stat.disk.last_level_count.bytes / > + (range_count + 1); > + range_size = MAX(range_size, MIN_RANGE_SIZE); > + return range_size; > +}