From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D5EE5A00C4; Sun, 6 Nov 2022 12:41:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DE2B40156; Sun, 6 Nov 2022 12:41:01 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 837D44003C for ; Sun, 6 Nov 2022 12:40:59 +0100 (CET) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id ECA745A; Sun, 6 Nov 2022 14:40:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru ECA745A DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1667734859; bh=2itjb+7jKT51aGsmKtXqxifDL4irhLYfpTcpQszMvfA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Mnx9s5qAHCp+0AvGW4k+Cwr5furgY181r74avQO4mEJf0VkQVXgxywotlgQOksr25 Kr1od+ZSOU0ljTZfBHEHdvvZ1EshwjdIQBGYa7tkuSxGpcxNPUSEGLWwujNmyzI+fS HelD8a3PzupPEpi2GobblYV0BiLmtr+YucL5NUWI= Message-ID: <4fe4589f-dbb0-9b97-f45f-91e7a9760322@oktetlabs.ru> Date: Sun, 6 Nov 2022 14:40:58 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v4 3/3] mempool: use cache for frequently updated stats Content-Language: en-US To: =?UTF-8?Q?Morten_Br=c3=b8rup?= , olivier.matz@6wind.com, mattias.ronnblom@ericsson.com, stephen@networkplumber.org, jerinj@marvell.com, bruce.richardson@intel.com Cc: hofors@lysator.liu.se, thomas@monjalon.net, dev@dpdk.org References: <20221104111740.330-1-mb@smartsharesystems.com> <20221104120329.1219-1-mb@smartsharesystems.com> <20221104120329.1219-3-mb@smartsharesystems.com> From: Andrew Rybchenko Organization: OKTET Labs In-Reply-To: <20221104120329.1219-3-mb@smartsharesystems.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 11/4/22 15:03, Morten Brørup wrote: > When built with stats enabled (RTE_LIBRTE_MEMPOOL_STATS defined), the > performance of mempools with caches is improved as follows. > > When accessing objects in the mempool, either the put_bulk and put_objs or > the get_success_bulk and get_success_objs statistics counters are likely > to be incremented. > > By adding an alternative set of these counters to the mempool cache > structure, accessing the dedicated statistics structure is avoided in the > likely cases where these counters are incremented. > > The trick here is that the cache line holding the mempool cache structure > is accessed anyway, in order to access the 'len' or 'flushthresh' fields. > Updating some statistics counters in the same cache line has lower > performance cost than accessing the statistics counters in the dedicated > statistics structure, which resides in another cache line. > > mempool_perf_autotest with this patch shows the following improvements in > rate_persec. > > The cost of enabling mempool stats (without debug) after this patch: > -6.8 % and -6.7 %, respectively without and with cache. > > v4: > * Fix checkpatch warnings: > A couple of typos in the patch description. > The macro to add to a mempool cache stat variable should not use > do {} while (0). Personally, I would tend to disagree with this, but > whatever keeps the CI happy. > v3: > * Don't update the description of the RTE_MEMPOOL_STAT_ADD macro. > This change belongs in the first patch of the series. > v2: > * Move the statistics counters into a stats structure. > > Signed-off-by: Morten Brørup Reviewed-by: Andrew Rybchenko [snip] > +/** > + * @internal When stats is enabled, store some statistics. > + * > + * @param cache > + * Pointer to the memory pool cache. > + * @param name > + * Name of the statistics field to increment in the memory pool cache. > + * @param n > + * Number to add to the statistics. > + */ > +#ifdef RTE_LIBRTE_MEMPOOL_STATS > +#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) (cache)->stats.name += n I'd enclose it in parenthesis. > +#else > +#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) do {} while (0) > +#endif > +