get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/119363/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 119363,
    "url": "http://patches.dpdk.org/api/patches/119363/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20221031112634.18329-3-mb@smartsharesystems.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20221031112634.18329-3-mb@smartsharesystems.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20221031112634.18329-3-mb@smartsharesystems.com",
    "date": "2022-10-31T11:26:34",
    "name": "[v2,3/3] mempool: use cache for frequently updated statistics",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "b773cda0cf31ae28dff2bc1d85588b45b8dc8fdd",
    "submitter": {
        "id": 591,
        "url": "http://patches.dpdk.org/api/people/591/?format=api",
        "name": "Morten Brørup",
        "email": "mb@smartsharesystems.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20221031112634.18329-3-mb@smartsharesystems.com/mbox/",
    "series": [
        {
            "id": 25495,
            "url": "http://patches.dpdk.org/api/series/25495/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=25495",
            "date": "2022-10-31T11:26:32",
            "name": "[v2,1/3] mempool: split statistics from debug",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/25495/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/119363/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/119363/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 0FBF7A00C5;\n\tMon, 31 Oct 2022 12:26:50 +0100 (CET)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 2C22440693;\n\tMon, 31 Oct 2022 12:26:42 +0100 (CET)",
            "from smartserver.smartsharesystems.com\n (smartserver.smartsharesystems.com [77.243.40.215])\n by mails.dpdk.org (Postfix) with ESMTP id 976EB40151\n for <dev@dpdk.org>; Mon, 31 Oct 2022 12:26:38 +0100 (CET)",
            "from dkrd2.smartsharesys.local ([192.168.4.12]) by\n smartserver.smartsharesystems.com with Microsoft SMTPSVC(6.0.3790.4675);\n Mon, 31 Oct 2022 12:26:37 +0100"
        ],
        "From": "=?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>",
        "To": "olivier.matz@6wind.com, andrew.rybchenko@oktetlabs.ru,\n stephen@networkplumber.org, jerinj@marvell.com, bruce.richardson@intel.com",
        "Cc": "thomas@monjalon.net, dev@dpdk.org,\n =?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>",
        "Subject": "[PATCH v2 3/3] mempool: use cache for frequently updated statistics",
        "Date": "Mon, 31 Oct 2022 12:26:34 +0100",
        "Message-Id": "<20221031112634.18329-3-mb@smartsharesystems.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20221031112634.18329-1-mb@smartsharesystems.com>",
        "References": "<20221030115445.2115-1-mb@smartsharesystems.com>\n <20221031112634.18329-1-mb@smartsharesystems.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-OriginalArrivalTime": "31 Oct 2022 11:26:37.0592 (UTC)\n FILETIME=[A3D42980:01D8ED1B]",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "When built with statistics enabled (RTE_LIBRTE_MEMPOOL_STATS defined), the\nperformance of mempools with caches is improved as follows.\n\nWhen accessing objects in the mempool, either the put_bulk and put_objs or\nthe get_success_bulk and get_success_objs statistics counters are likely\nto be incremented.\n\nBy adding an alternative set of these counters to the mempool cache\nstructure, accesing the dedicated statistics structure is avoided in the\nlikely cases where these counters are incremented.\n\nThe trick here is that the cache line holding the mempool cache structure\nis accessed anyway, in order to access the 'len' or 'flushthresh' fields.\nUpdating some statistics counters in the same cache line has lower\nperformance cost than accessing the statistics counters in the dedicated\nstatistics structure, which resides in another cache line.\n\nmempool_perf_autotest with this patch shows the follwing change in\nrate_persec.\n\nCompared to only spliting statistics from debug:\n+1.5 % and +14.4 %, respectively without and with cache.\n\nCompared to not enabling mempool stats:\n-4.4 % and -9.9 %, respectively without and with cache.\n\nv2:\n* Move the statistics counters into a stats structure.\n\nSigned-off-by: Morten Brørup <mb@smartsharesystems.com>\n---\n lib/mempool/rte_mempool.c |  9 +++++\n lib/mempool/rte_mempool.h | 73 ++++++++++++++++++++++++++++++++-------\n 2 files changed, 69 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c\nindex e6208125e0..a18e39af04 100644\n--- a/lib/mempool/rte_mempool.c\n+++ b/lib/mempool/rte_mempool.c\n@@ -1286,6 +1286,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)\n \t\tsum.get_success_blks += mp->stats[lcore_id].get_success_blks;\n \t\tsum.get_fail_blks += mp->stats[lcore_id].get_fail_blks;\n \t}\n+\tif (mp->cache_size != 0) {\n+\t\t/* Add the statistics stored in the mempool caches. */\n+\t\tfor (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {\n+\t\t\tsum.put_bulk += mp->local_cache[lcore_id].stats.put_bulk;\n+\t\t\tsum.put_objs += mp->local_cache[lcore_id].stats.put_objs;\n+\t\t\tsum.get_success_bulk += mp->local_cache[lcore_id].stats.get_success_bulk;\n+\t\t\tsum.get_success_objs += mp->local_cache[lcore_id].stats.get_success_objs;\n+\t\t}\n+\t}\n \tfprintf(f, \"  stats:\\n\");\n \tfprintf(f, \"    put_bulk=%\"PRIu64\"\\n\", sum.put_bulk);\n \tfprintf(f, \"    put_objs=%\"PRIu64\"\\n\", sum.put_objs);\ndiff --git a/lib/mempool/rte_mempool.h b/lib/mempool/rte_mempool.h\nindex 16e7e62e3c..5806e75609 100644\n--- a/lib/mempool/rte_mempool.h\n+++ b/lib/mempool/rte_mempool.h\n@@ -86,6 +86,21 @@ struct rte_mempool_cache {\n \tuint32_t size;\t      /**< Size of the cache */\n \tuint32_t flushthresh; /**< Threshold before we flush excess elements */\n \tuint32_t len;\t      /**< Current cache count */\n+\tuint32_t unused0;\n+#ifdef RTE_LIBRTE_MEMPOOL_STATS\n+\t/*\n+\t * Alternative location for the most frequently updated mempool statistics (per-lcore),\n+\t * providing faster update access when using a mempool cache.\n+\t */\n+\tstruct {\n+\t\tuint64_t put_bulk;          /**< Number of puts. */\n+\t\tuint64_t put_objs;          /**< Number of objects successfully put. */\n+\t\tuint64_t get_success_bulk;  /**< Successful allocation number. */\n+\t\tuint64_t get_success_objs;  /**< Objects successfully allocated. */\n+\t} stats;                        /**< Statistics */\n+#else\n+\tuint64_t unused1[4];\n+#endif\n \t/**\n \t * Cache objects\n \t *\n@@ -296,14 +311,14 @@ struct rte_mempool {\n \t| RTE_MEMPOOL_F_NO_IOVA_CONTIG \\\n \t)\n /**\n- * @internal When debug is enabled, store some statistics.\n+ * @internal When stats is enabled, store some statistics.\n  *\n  * @param mp\n  *   Pointer to the memory pool.\n  * @param name\n  *   Name of the statistics field to increment in the memory pool.\n  * @param n\n- *   Number to add to the object-oriented statistics.\n+ *   Number to add to the statistics.\n  */\n #ifdef RTE_LIBRTE_MEMPOOL_STATS\n #define RTE_MEMPOOL_STAT_ADD(mp, name, n) do {                  \\\n@@ -312,6 +327,23 @@ struct rte_mempool {\n #else\n #define RTE_MEMPOOL_STAT_ADD(mp, name, n) do {} while (0)\n #endif\n+/**\n+ * @internal When stats is enabled, store some statistics.\n+ *\n+ * @param cache\n+ *   Pointer to the memory pool cache.\n+ * @param name\n+ *   Name of the statistics field to increment in the memory pool cache.\n+ * @param n\n+ *   Number to add to the statistics.\n+ */\n+#ifdef RTE_LIBRTE_MEMPOOL_STATS\n+#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) do { \\\n+\t\t(cache)->stats.name += n;               \\\n+\t} while (0)\n+#else\n+#define RTE_MEMPOOL_CACHE_STAT_ADD(cache, name, n) do {} while (0)\n+#endif\n \n /**\n  * @internal Calculate the size of the mempool header.\n@@ -1327,13 +1359,17 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table,\n {\n \tvoid **cache_objs;\n \n+\t/* No cache provided */\n+\tif (unlikely(cache == NULL))\n+\t\tgoto driver_enqueue;\n+\n \t/* increment stat now, adding in mempool always success */\n-\tRTE_MEMPOOL_STAT_ADD(mp, put_bulk, 1);\n-\tRTE_MEMPOOL_STAT_ADD(mp, put_objs, n);\n+\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, put_bulk, 1);\n+\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, put_objs, n);\n \n-\t/* No cache provided or the request itself is too big for the cache */\n-\tif (unlikely(cache == NULL || n > cache->flushthresh))\n-\t\tgoto driver_enqueue;\n+\t/* The request itself is too big for the cache */\n+\tif (unlikely(n > cache->flushthresh))\n+\t\tgoto driver_enqueue_stats_incremented;\n \n \t/*\n \t * The cache follows the following algorithm:\n@@ -1358,6 +1394,12 @@ rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table,\n \n driver_enqueue:\n \n+\t/* increment stat now, adding in mempool always success */\n+\tRTE_MEMPOOL_STAT_ADD(mp, put_bulk, 1);\n+\tRTE_MEMPOOL_STAT_ADD(mp, put_objs, n);\n+\n+driver_enqueue_stats_incremented:\n+\n \t/* push objects to the backend */\n \trte_mempool_ops_enqueue_bulk(mp, obj_table, n);\n }\n@@ -1464,8 +1506,8 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,\n \tif (remaining == 0) {\n \t\t/* The entire request is satisfied from the cache. */\n \n-\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);\n-\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);\n+\t\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);\n+\t\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_objs, n);\n \n \t\treturn 0;\n \t}\n@@ -1494,8 +1536,8 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,\n \n \tcache->len = cache->size;\n \n-\tRTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);\n-\tRTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);\n+\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);\n+\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_objs, n);\n \n \treturn 0;\n \n@@ -1517,8 +1559,13 @@ rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,\n \t\tRTE_MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);\n \t\tRTE_MEMPOOL_STAT_ADD(mp, get_fail_objs, n);\n \t} else {\n-\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);\n-\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);\n+\t\tif (likely(cache != NULL)) {\n+\t\t\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_bulk, 1);\n+\t\t\tRTE_MEMPOOL_CACHE_STAT_ADD(cache, get_success_objs, n);\n+\t\t} else {\n+\t\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);\n+\t\t\tRTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);\n+\t\t}\n \t}\n \n \treturn ret;\n",
    "prefixes": [
        "v2",
        "3/3"
    ]
}