From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 6 Feb 2019 11:53:02 +0300 From: Vladimir Davydov Subject: Re: [tarantool-patches] Re: [PATCH 7/9] vinyl: randomize range compaction to avoid IO load spikes Message-ID: <20190206085302.3xzjz2udfvdin5ld@esperanza> References: <44f34fbaf09af5d1054f2e4843a77e095afe1e71.1548017258.git.vdavydov.dev@gmail.com> <20190122125458.cutoz5rtfd2sb6el@esperanza> <20190205173958.GG6811@chai> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190205173958.GG6811@chai> To: Konstantin Osipov Cc: tarantool-patches@freelists.org List-ID: On Tue, Feb 05, 2019 at 08:39:58PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov [19/01/22 15:56]: > > I ran some tests and, surprisingly, it turned out that randomization > > didn't help at all: the compaction queue size jumped up to 30% and even > > 40% from time to time although there was plenty of compaction power - > > compaction threads were busy only half of the time. When I looked > > closer, I saw that the queue size behavior looked weird - it jumped > > after a dump for a very short period of time, until the next dump, which > > pushed it back to 10%. This made me wonder how it could happen at all - > > normally, compaction queue should only grow after a dump, not diminish. > > > I think I've finally found the root cause of the problem. The code > > computing compaction priority (see vy_range_update_compaction_priority) > > is unstable meaning the size of the first level equals the size of the > > smallest run so if memory dumps produce runs of varying sizes, which is > > what happens in practice in contrast to simulation, the shape of the > > tree will vary as well, resulting in different compaction priority and > > unstable queue behavior. > > > > We must fix this somehow. One way to do it is compute the first level > > size basing on the size of the last level run, which is constant most of > > the time, and indeed, when I did it and reran the tests, I found that > > the queue stayed below 10% all the time. Turning off randomization, made > > the queue jump up to 30%, which was expected. The diff is below. I'll > > spruce it up a little, wrap it nicely, and submit it separately later. > > Why not use a simple weighted average? Over how many dumps? What do we do after restart, when there's no history and perhaps even no level 1?