From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 24 May 2018 09:15:20 +0300 From: Vladimir Davydov Subject: Re: [PATCH v2 2/2] memtx: run garbage collection on demand Message-ID: <20180524061520.svdeb7o72tvw663m@esperanza> References: <40168332447f753d7ef7d32857ca7d5b0d9ed900.1527009486.git.vdavydov.dev@gmail.com> <20180523175846.GE4266@atlas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180523175846.GE4266@atlas> To: Konstantin Osipov Cc: tarantool-patches@freelists.org List-ID: On Wed, May 23, 2018 at 08:58:46PM +0300, Konstantin Osipov wrote: > * Vladimir Davydov [18/05/22 20:29]: > > - void *ret = mempool_alloc(&memtx->index_extent_pool); > > + void *ret; > > + while ((ret = mempool_alloc(&memtx->index_extent_pool)) == NULL) { > > + bool stop; > > + memtx_engine_run_gc(memtx, &stop); > > + if (stop) > > + break; > > + } > > if (ret == NULL) > > diag_set(OutOfMemory, MEMTX_EXTENT_SIZE, > > "mempool", "new slab"); > > @@ -1184,6 +1196,10 @@ memtx_index_extent_reserve(struct memtx_engine *memtx, int num) > > while (memtx->num_reserved_extents < num) { > > void *ext = mempool_alloc(&memtx->index_extent_pool); > > if (ext == NULL) { > > + bool stop; > > + memtx_engine_run_gc(memtx, &stop); > > + if (!stop) > > + continue; > > diag_set(OutOfMemory, MEMTX_EXTENT_SIZE, > > "mempool", "new slab"); > > return -1; > > I would rewrite this loop in the same idiomatic style as the > previous one to avoid if (!stop) check. OK, will do before pushing it. > > OK to push.