[PATCH v2 2/2] memtx: run garbage collection on demand

Konstantin Osipov kostja at tarantool.org
Wed May 23 20:58:46 MSK 2018


* Vladimir Davydov <vdavydov.dev at gmail.com> [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



More information about the Tarantool-patches mailing list