]> granicus.if.org Git - pdns/commitdiff
calidns: Add a maximum-qps option to stay at a given stable load
authorRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 21 Apr 2018 20:18:43 +0000 (22:18 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Sat, 21 Apr 2018 20:25:13 +0000 (22:25 +0200)
docs/manpages/calidns.1.rst
pdns/calidns.cc

index e43a83268690a2f5178cdcd12ba200421ec3c2c2..c7b943de30a87ff23e3c43b71c6e05d483a4dfae 100644 (file)
@@ -32,6 +32,10 @@ This is similar to Alexa top 1 million list.
 Options
 -------
 
+--ecs <SUBNET>           Add EDNS Client Subnet option to outgoing queries using random
+                         addresses from the specified *SUBNET* range (IPv4 only).
 --increment <NUM>        On every subsequent run, multiply the number of queries per second
                          by *NUM*. By default, this is 1.1.
+--maximum-qps <NUM>      Stop incrementing once this rate has been reached, to provide a
+                         stable load.
 --want-recursion         Set this flag to send queries with the Recursion Desired flag set.
index f8b358ea47992e7ab8c839d78b6ea3938834e1c8..9fb42fb975d86366cbf143c448fc3c236dd26751 100644 (file)
@@ -223,6 +223,7 @@ try
     ("version", "Show the version number")
     ("ecs", po::value<string>(), "Add EDNS Client Subnet option to outgoing queries using random addresses from the specified range (IPv4 only)")
     ("increment", po::value<float>()->default_value(1.1),  "Set the factor to increase the QPS load per run")
+    ("maximum-qps", po::value<uint32_t>(), "Stop incrementing once this rate has been reached, to provide a stable load")
     ("want-recursion", "Set the Recursion Desired flag on queries");
   po::options_description alloptions;
   po::options_description hidden("hidden options");
@@ -274,6 +275,11 @@ try
   hitrate /= 100;
   uint32_t qpsstart = g_vm["initial-qps"].as<uint32_t>();
 
+  uint32_t maximumQps = std::numeric_limits<uint32_t>::max();
+  if (g_vm.count("maximum-qps")) {
+    maximumQps = g_vm["maximum-qps"].as<uint32_t>();
+  }
+
   Netmask ecsRange;
   if (g_vm.count("ecs")) {
     dns_random_init("0123456789abcdef");
@@ -347,10 +353,10 @@ try
     sockets.push_back(sock);
   }
   new thread(recvThread, &sockets);
-  int qps;
+  uint32_t qps;
 
   ofstream plot("plot");
-  for(qps=qpsstart;;qps *= increment) {
+  for(qps=qpsstart;;) {
     double seconds=1;
     cout<<"Aiming at "<<qps<< "qps (RD="<<wantRecursion<<") for "<<seconds<<" seconds at cache hitrate "<<100.0*hitrate<<"%";
     unsigned int misses=(1-hitrate)*qps*seconds;
@@ -392,6 +398,9 @@ try
     cout<<"Received "<<g_recvcounter.load()<<" packets ("<<perc<<"%)"<<endl;
     plot<<qps<<" "<<realqps<<" "<<perc<<" "<<g_recvcounter.load()/(udiff/1000000.0)<<" " << 8*g_recvbytes.load()/(udiff/1000000.0)<<endl;
     plot.flush();
+    if (qps < maximumQps) {
+      qps *= increment;
+    }
   }
   plot.flush();
   // t1.detach();