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 DB36EA0032 for ; Wed, 29 Sep 2021 22:25:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6B2FD410EA; Wed, 29 Sep 2021 22:25:17 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 87AC5410EA for ; Wed, 29 Sep 2021 22:25:16 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id w29so6268492wra.8 for ; Wed, 29 Sep 2021 13:25:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0DUvC2Ow09vwOkRAqu314C5OMTsEzR6kKLJeCRsQW3k=; b=SBkbG6Cuk09sMel0hqx2bax6GUiNabz98+nteWBF/L+KnXIEi1dFd86gYXjUdWevmW ryXBcmHrjwBTZgJ6nnWhp88LwA3ysZE0DkRRjQfuF0HiPzSvUxIqXYasyGJYdV00xdb5 jyPJsfSCnJlgtI4jv+iD06E0Eg8b2ZQswTBCuy4cwjKliFk+PA1oZOTowIiuYWZO0/1v //cYRMtcDAEWfzgCUlM1btI1tMeQ52a+KWiE01zH0R0DvwUwnPyk3uSi7PXIW5X96sgp 05wMEXXmBBQjchYUM8ddO9fbanAvXoMaVcbDq7esfPQYP9hNUmbmaEU7ASG18Mnj8inx PaNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0DUvC2Ow09vwOkRAqu314C5OMTsEzR6kKLJeCRsQW3k=; b=DK/ahcRbC7VV4l3OkvOvvrazlmpt6MC+lTnjm/JkQ1Jj3J2K27TdxAFuXAPBzrElNg MYQQ8eeNo1A3fVlogl28vvMV91Sg12h7avwpp5hHOJdxN+hQXl0hkL6T2gks4gnHKY4a kITd8z6RC4Zc01m6MIsLTbIGcSzs6D1is5QH5vRYZ4/TpBpu2u7Y8zkuLx5Jkqi2yQEq qapE6SQuPI18Kiqk28yHXto96QxVr0fKYw4a1OhqlNuXqKxRx3ZKUbTuUGSVcRymiYso PoEVsV63vKEly+XxVVek6auOs3N/kHgZxt5N4JtB0MYTxqjwlhKlPraafS38Wpsn+Mcs 4YLg== X-Gm-Message-State: AOAM532sam8CNPWR3IwcGBDbjxt5RiJauVGuVo7mU6esbsSqO+r34uB/ y09LtH2lTElRNTZfEblGQMYjCg== X-Google-Smtp-Source: ABdhPJzB9edhqyn6rExYuzl4WkYMbJQSOCs+0/IZo6qaPJp+33kULBfAgvVcalH9xk8yauWOsUf+CQ== X-Received: by 2002:a5d:4d84:: with SMTP id b4mr2305817wru.258.1632947116207; Wed, 29 Sep 2021 13:25:16 -0700 (PDT) Received: from 6wind.com ([2a01:e0a:5ac:6460:c065:401d:87eb:9b25]) by smtp.gmail.com with ESMTPSA id r9sm931993wru.2.2021.09.29.13.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 13:25:15 -0700 (PDT) Date: Wed, 29 Sep 2021 22:25:14 +0200 From: Olivier Matz To: Thomas Monjalon Cc: topperxin , "users@dpdk.org" , andrew.rybchenko@oktetlabs.ru Subject: Re: [dpdk-users] what's the cache size of rte_mempool_create()? Message-ID: References: <5a53ec0f.4a37.17bc4b38e33.Coremail.topperxin@126.com> <8006744.t41pDv0jej@thomas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8006744.t41pDv0jej@thomas> X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Hi, On Wed, Sep 29, 2021 at 12:48:24PM +0200, Thomas Monjalon wrote: > +Cc mempool maintainers > > 08/09/2021 11:18, topperxin: > > HI list > > A question about the value of cache size of rte_mempool_crate() function, the defination of this function like below: > > > > > > struct rte_mempool * > > > > rte_mempool_create(const char *name, unsigned n, unsigned elt_size, > > > > unsigned cache_size, unsigned private_data_size, > > > > rte_mempool_ctor_t *mp_init, void *mp_init_arg, > > > > rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, > > > > int socket_id, unsigned flags); > > > > > > > > > > > > My question is : what's cache_size value means ? what's difference between if I set cache_size = 0 and cache_size = 512 ? > > I get some information from the the dpdk 20.11 it said that, if we set cache size to 0 , it can be useful to avoid losing objects in cache , I can't understand this point, does it mean > > that if we set the cache size to non zero, it will suffer the risk that some packages will lost ? right ? > > In summary, a mempool cache is a per-core table where object pointers (mbuf pointers in case of mbuf pool) are stored temporarilly. When the cache is full, pointers are returned to the common pool. When the cache is empty, it is refilled from the common pool. The advantage is to reduce the contention on the common pool, increasing performance (the per-core cache does not need lock or atomic operations). The drawback is that a core cannot get objects from the cache of another core. In short, when you want to be sure to be able to allocate 1000 objects, you need to create a mempool with a size of 1000 + (nb_core * cache_size). If cache size is 0, there is no cache, i.e. all mempool get/put are done from the common pool, which is slower. More in the documentation: https://doc.dpdk.org/guides/prog_guide/mempool_lib.html Regards, Olivier > > > > Thanks for your tips. > > > > > > BR. > > > >