From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 9989524495 for ; Sat, 6 Jul 2019 16:59:18 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wNonw71gVxMk for ; Sat, 6 Jul 2019 16:59:18 -0400 (EDT) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id DDE7C23268 for ; Sat, 6 Jul 2019 16:59:17 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/2] swim: pool IO tasks References: <20190705230136.GD30966@atlas> From: Vladislav Shpilevoy Message-ID: <609c7e7b-d8f7-413b-752c-94034bfd689b@tarantool.org> Date: Sat, 6 Jul 2019 23:00:28 +0200 MIME-Version: 1.0 In-Reply-To: <20190705230136.GD30966@atlas> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: Konstantin Osipov Cc: tarantool-patches@freelists.org On 06/07/2019 01:01, Konstantin Osipov wrote: > * Vladislav Shpilevoy [19/07/06 01:39]: >> + >> +/** >> + * All the SWIM instances and their members use the same objects >> + * to send data - tasks. Each task is ~1.5KB, and on one hand it >> + * would be a waste of memory to keep preallocated tasks for each >> + * member. One the other hand it would be too slow to allocate >> + * and delete ~1.5KB on each interaction, ~3KB on each round step. >> + * Here is a pool of free tasks shared among all SWIM instances >> + * to avoid allocations, but do not keep a separate task for each >> + * member. >> + */ >> +static struct stailq swim_task_pool; >> +/** Number of pooled tasks. */ >> +static int swim_task_pool_size = 0; > > These should be thread-local. Why? SWIM works in one thread, these values are never accessed from another one. They would be just copied for each thread and unused in all but one. > > Why not use mempool? > > Because 1) it is an overkill, 2) I don't want to depend on slab allocator, 3) it just does not fit this case, according to mempool description from mempool.h: "Good for allocating tons of small objects of the same size.".