summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-03-26 16:28:47 +0100
committerDaniel Borkmann <dborkman@redhat.com>2014-03-26 16:35:36 +0100
commitc10621e6fa8de50619d7dd28546dd3288f053ab8 (patch)
tree7ddd1e3fa87c8cce6348404163b5c266b4d8e1f6
parentc139e809f8562a2e9a1e24e86abc5a7c6eee6254 (diff)
trafgen: keep a small initial ring buffer size to reduce cache-misses
Heavily reduce the initial ring buffer size for trafgen to just 196KiB, so that we can heavily reduce the number of cache-misses related to cache references. People can still overwrite this setting later on via command line option for their specific architecture if they wish. Perhaps the RX_RING should be checked as well in netsniff-ng though the use case there is slightly different. Before: Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000': 137,765,493,346 instructions:k # 0.82 insns per cycle 167,438,826,578 cycles:k # 0.000 GHz 59,508,315 branch-misses:k 361 context-switches:k 6 cpu-migrations:k 134,751,541 cache-misses:k # 85.019 % of all cache refs 158,495,358 cache-references:k 755 kmem:kmem_cache_alloc 15.139458202 seconds time elapsed After: Performance counter stats for 'trafgen -i blub -o dummy0 -n100000000': 137,889,782,650 instructions:k # 0.92 insns per cycle 150,239,185,971 cycles:k # 0.000 GHz 71,583,573 branch-misses:k 423 context-switches:k 7 cpu-migrations:k 60,239 cache-misses:k # 0.073 % of all cache refs 82,502,468 cache-references:k 740 kmem:kmem_cache_alloc 12.028787964 seconds time elapsed Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
-rw-r--r--trafgen.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/trafgen.c b/trafgen.c
index f50ac22..af15ef2 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -874,6 +874,9 @@ int main(int argc, char **argv)
ctx.gid = getgid();
ctx.qdisc_path = false;
+ /* Keep an initial small default size to reduce cache-misses. */
+ ctx.reserve_size = 196 * (1 << 10);
+
while ((c = getopt_long(argc, argv, short_options, long_options,
&opt_index)) != EOF) {
switch (c) {