graph: add optional profiling stats
PATCH v2 1/1 graph: add optional profiling stats
Added graph node profiling stats, build time configurable by enabling RTE_GRAPH_PROFILE in rte_config.h.
Signed-off-by Morten Brørup <[email protected]>
---
v2:
* Fix indentation.
--- config/rte_config.h | 1 + lib/graph/graph_debug.c | 29 ++++++++++++++++++++++++++++- lib/graph/node.c | 2 ++ lib/graph/rte_graph_worker_common.h | 23 ++++++++++++++++++++--- 4 files changed, 51 insertions(+), 4 deletions(-)
config/rte_config.h +1 -0
@@ -106,6 +106,7 @@/* rte_graph defines */ #define RTE_GRAPH_BURST_SIZE 256#define RTE_LIBRTE_GRAPH_STATS 1 +/* RTE_GRAPH_PROFILE is not set */ /****** driver defines ********/
lib/graph/graph_debug.c +28 -1
@@ -92,7 +92,34 @@ rte_graph_obj_dump(FILE *f, struct rte_graph *g, bool all)fprintf (f," total_sched_fail=%" PRId64"\n" , n->dispatch.total_sched_fail); } -fprintf (f," total_calls=%" PRId64"\n" , n->total_calls); +fprintf (f," total_calls=%" PRIu64"\n" , n->total_calls); +fprintf (f," total_cycles=%" PRIu64"\n" , n->total_cycles); +#ifdef RTE_GRAPH_PROFILE +uint64_t calls_2_or_more = n->total_calls - + (n->usage_stats[0 ].calls + n->usage_stats[1 ].calls); +double avg_objs_2_or_more = calls_2_or_more ==0 ? (double )2 : + (double )(n->total_objs - n->usage_stats[1 ].calls) / + (double )calls_2_or_more; +fprintf (f," calls_0=%" PRIu64", _1=%" PRIu64", _%.1f=%" PRIu64"\n" , + n->usage_stats[0 ].calls, + n->usage_stats[1 ].calls, + avg_objs_2_or_more, + calls_2_or_more); +fprintf (f," cycles_0=%" PRIu64", _1=%" PRIu64", _%.1f=%" PRIu64"\n" , + n->usage_stats[0 ].cycles, + n->usage_stats[1 ].cycles, + avg_objs_2_or_more, + n->total_cycles - + (n->usage_stats[0 ].cycles + n->usage_stats[1 ].cycles)); +fprintf (f," cycles_per_call_1=%.1f, _%.1f=%.1f\n" , + n->usage_stats[1 ].calls ==0 ? (double )0 : + (double )n->usage_stats[1 ].cycles / (double )n->usage_stats[1 ].calls, + avg_objs_2_or_more, + calls_2_or_more ==0 ? (double )0 : + (double )(n->total_cycles - + (n->usage_stats[0 ].cycles + n->usage_stats[1 ].cycles)) / + (double )calls_2_or_more); +#endif for (i =0 ; i < n->nb_edges; i++)fprintf (f," edge[%d] <%s>\n" , i, n->nodes[i]->name);
lib/graph/node.c +2 -0
@@ -110,10 +110,12 @@ __rte_node_register(const struct rte_node_register *reg)rte_edge_t i;size_t sz; +#ifndef RTE_GRAPH_PROFILE /* Limit Node specific metadata to one cacheline on 64B CL machine */ RTE_BUILD_BUG_ON ((offsetof(struct rte_node , nodes) - offsetof(struct rte_node , ctx)) !=RTE_CACHE_LINE_MIN_SIZE ); +#endif graph_spinlock_lock ();
lib/graph/rte_graph_worker_common.h +20 -3
@@ -144,12 +144,22 @@ struct __rte_cache_aligned rte_node {rte_node_process_t process;/**< Process function. */ uint64_t process_u64; }; +/** Fast path area cache line 3. */ +#ifdef RTE_GRAPH_PROFILE +struct { +uint64_t calls; +uint64_t cycles; + } usage_stats[2 ];/**< Usage when this node processed 0 or 1 objects. */ +/** Fast path area cache line 4. */ +#endif alignas(RTE_CACHE_LINE_MIN_SIZE )struct rte_node *nodes[];/**< Next nodes. */ }; }; +#ifndef RTE_GRAPH_PROFILE static_assert (offsetof(struct rte_node , nodes) - offsetof(struct rte_node , ctx) ==RTE_CACHE_LINE_MIN_SIZE ,"rte_node fast path area must fit in 64 bytes" ); +#endif /** * @internal
@@ -197,7 +207,7 @@ void __rte_node_stream_alloc_size(struct rte_graph *graph, static __rte_always_inline void__rte_node_process (struct rte_graph *graph,struct rte_node *node) { -uint64_t start; +uint64_t cycles;uint16_t rc;void **objs;
@@ -206,11 +216,18 @@ __rte_node_process(struct rte_graph *graph, struct rte_node *node)rte_prefetch0 (objs);if (rte_graph_has_stats_feature ()) { - start =rte_rdtsc (); + cycles = -rte_rdtsc (); rc = node->process (graph, node, objs, node->idx); - node->total_cycles +=rte_rdtsc () - start; + cycles +=rte_rdtsc (); + node->total_cycles += cycles; node->total_calls++; node->total_objs += rc; +#ifdef RTE_GRAPH_PROFILE +if (rc <=1 ) { + node->usage_stats[rc].calls++; + node->usage_stats[rc].cycles += cycles; + } +#endif }else { node->process (graph, node, objs, node->idx); }
Signature · 1 line
2.43.0