Skip to contentSkip to conversation

mempool: optimized debug statistics

PATCH New Morten Brørup 1 participant 1 message Oct 27, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mempool: optimized debug statistics

When built with debug enabled (RTE_LIBRTE_MEMPOOL_DEBUG defined), the performance of mempools with caches is improved as follows.

Accessing objects in the mempool is likely to increment either the put_bulk and put_objs or the get_success_bulk and get_success_objs debug statistics counters.

By adding an alternative set of these counters to the mempool cache structure, accessing the dedicated debug 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 update the "len" field. Updating some debug statistics counters in the same cache line has lower performance cost than accessing the debug statistics counters in the dedicated debug statistics structure, i.e. in another cache line.

Running mempool_perf_autotest on a VMware virtual server shows an avg. increase of 6.4 % in rate_persec for the tests with cache. (Only when built with debug enabled, obviously!)

For the tests without cache, the avg. increase in rate_persec is 0.8 %. I assume this is noise from the test environment.

v2:
* Fix spelling and repeated word in commit message, caught by checkpatch.

---
 lib/mempool/rte_mempool.c |  7 +++++
 lib/mempool/rte_mempool.h | 55 +++++++++++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 11 deletions(-)
lib/mempool/rte_mempool.c +7 -0
index 21c94a2b9f..7b8c00a022 100644
@@ -1285,6 +1285,13 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 		sum.get_fail_objs += mp->stats[lcore_id].get_fail_objs;
 		sum.get_success_blks += mp->stats[lcore_id].get_success_blks;
 		sum.get_fail_blks += mp->stats[lcore_id].get_fail_blks;
+		/* Add the fast access statistics, if local caches exist */
+		if (mp->cache_size != 0) {
+			sum.put_bulk += mp->local_cache[lcore_id].put_bulk;
+			sum.put_objs += mp->local_cache[lcore_id].put_objs;
+			sum.get_success_bulk += mp->local_cache[lcore_id].get_success_bulk;
+			sum.get_success_objs += mp->local_cache[lcore_id].get_success_objs;
+		}
 	}
 	fprintf(f, "  stats:\n");
 	fprintf(f, "    put_bulk=%"PRIu64"\n", sum.put_bulk);
lib/mempool/rte_mempool.h +44 -11

93 lines not on this page · raw message

Signature · 1 line
2.17.1