From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 23 May 2018 20:58:46 +0300 From: Konstantin Osipov Subject: Re: [PATCH v2 2/2] memtx: run garbage collection on demand Message-ID: <20180523175846.GE4266@atlas> References: <40168332447f753d7ef7d32857ca7d5b0d9ed900.1527009486.git.vdavydov.dev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40168332447f753d7ef7d32857ca7d5b0d9ed900.1527009486.git.vdavydov.dev@gmail.com> To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: * 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 to push. -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov