From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f66.google.com (mail-vk0-f66.google.com [209.85.213.66]) by dpdk.org (Postfix) with ESMTP id CD505FFA for ; Mon, 6 Feb 2017 22:07:36 +0100 (CET) Received: by mail-vk0-f66.google.com with SMTP id 23so7974286vkc.2 for ; Mon, 06 Feb 2017 13:07:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=iJx5Rz6M2pkzdBJwvJZKVGoZY/RqMTF/qNPEsgpbB70=; b=vEYmG3CzzZX9aDBvGPAsSrF2Vv1MOrX78DrmH+Q41xqPD1tJzZsrK/MVD+OGB9FsAQ cn+ulKRA20IfMKHeXFZZW3okpBYC/eSoIpcB1+C44wR45b9Ls+SfXqMLeFl2/RrJqIH4 M1cnimYJshjmB4dYfQ2aCrBkW1pNLN50X8STS9eiB0+UasQ9R3HWccD9fBV4H5CnvQ+g 4Ktb1v1XfENSO6SCitKMEoWNvzvopCslZ7odjCWnk44Q+eUiGMFt+cESLpNNNCq3f9fn 679sMbkhXDSj6xZiimt0AcorwI98S/6CTojsqzp1i0O3thPEhyTyzy4jTpuFNIIYvkP6 7qyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=iJx5Rz6M2pkzdBJwvJZKVGoZY/RqMTF/qNPEsgpbB70=; b=XMrZ72HUMV2PtbiT34pfFqMMEY81jg+DbSaztXBjDAg9IvTfTQtVJ8YvayIlyKfQKv 9teGjU5u6R90MDXxDmBlu/HrEWrJfVvOn31ERKMdhY9BfwY+crhimMP054DSQDF2P/TR oCvVAwHwKSvNOae2UytuDhgiqRadqER1X414nQ0PTIO4oQmmJJXXfuQQfwuZXJzJ68tM Jiro2J814Lz6604mt2mRP1vq18RBLYePoFIBevAMJF8HGYUx36M/t0VJjrts2UPI2li1 KI4gOiON3IC4PR5Ae7QJuBQNMpW++73ET5VV/3Nsv6rclFlQO7Rx8FfSeqml6GgD421E cITA== X-Gm-Message-State: AMke39kYVqyBLy2TSSbgALS+eDBWPc45FN66SXuKKG2nQPNHS6Gr82eXOXIZGtSGzeDrYCN7FRr8dqtb8R0D0w== X-Received: by 10.31.107.74 with SMTP id g71mr4630996vkc.116.1486415255986; Mon, 06 Feb 2017 13:07:35 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.136.7 with HTTP; Mon, 6 Feb 2017 13:07:35 -0800 (PST) In-Reply-To: <20170206145105.6a9016ec@platinum> References: <790E2AC11206AC46B8F4BB82078E34F8062736DF@EXUSMBX02.AD.MLP.com> <20170206145105.6a9016ec@platinum> From: Pavel Shirshov Date: Mon, 6 Feb 2017 13:07:35 -0800 Message-ID: To: Olivier Matz Cc: vlad.lazarenko@worldquant.com, users@dpdk.org Content-Type: text/plain; charset=UTF-8 Subject: Re: [dpdk-users] Optimal number of elements in mempool n = (2^q - 1) vs examples, what is the right thing to do? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Feb 2017 21:07:37 -0000 Hi Olivier, It's a good explanation of rte_mempool internals. I think it would be good to have your comment in the rte_mempool documentation. Could we add it there? Thanks On Mon, Feb 6, 2017 at 5:51 AM, Olivier Matz wrote: > Hi Vlad, > > On Wed, 1 Feb 2017 16:54:57 +0000, Vlad.Lazarenko at worldquant.com > (Lazarenko, Vlad (WorldQuant)) wrote: >> Hello, >> >> I'm new to DPDK and have noticed that documentation for >> rte_mempool_create states that the optimal size for a number of >> elements in the pool is n = (2^q-1). But in many examples it is >> simply set to 2^q (multi_process/simple_mp/main.c uses 2014, for >> example). This is a bit confusing. Is 2^q - 1 really the optimal >> number but examples don't use it, or maybe the documentation for the >> mempool is wrong, or...? If anyone could shed some light on this >> that'd be helpful. > > That's true for rte_mempool based on a rte_ring (this is the default, > but since recently, it's possible to use another handler). > > The size of a rte_ring is (2^n - 1), because one element in the ring is > reserved to distinguish between a full an an empty ring. So, when a > mempool uses a ring, if we ask for 2^n elements, a ring of size > (2^(n+1) - 1) is created, which can consume additional memory. > > On the other hand, the mempool object size is often much larger than > a ring entry (usually 8 bytes, the size of a pointer), especially > knowing that by default, the objects are cache aligned (usually 64 > bytes). > > So we may remove this note in the future since it's not very relevant. > > Regards, > Olivier > >> >> ################################################################################### >> >> The information contained in this communication is confidential, may >> be >> >> subject to legal privilege, and is intended only for the individual >> named. >> >> If you are not the named addressee, please notify the sender >> immediately and >> >> delete this email from your system. The views expressed in this >> email are >> >> the views of the sender only. Outgoing and incoming electronic >> communications >> >> to this address are electronically archived and subject to review >> and/or disclosure >> >> to someone other than the recipient. >> >> ################################################################################### > > > You can remove this confidential notice for public mailing list :) >