]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
storage: rename the latency key names so they sort properly
authorBrian Warner <warner@lothar.com>
Sat, 12 Jul 2008 04:51:02 +0000 (21:51 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 12 Jul 2008 04:51:02 +0000 (21:51 -0700)
src/allmydata/storage.py
src/allmydata/test/test_storage.py

index 775c47e399d55e3d6d0bd423b8691b7781a31dd4..4029d966a740981fee8526f13ea9fc333d0f233d 100644 (file)
@@ -821,10 +821,11 @@ class StorageServer(service.MultiService, Referenceable):
     def get_latencies(self):
         """Return a dict, indexed by category, that contains a dict of
         latency numbers for each category. Each dict will contain the
-        following keys: mean, median, 1_percentile, 10_percentile,
-        90_percentile, 95_percentile, 99_percentile, 999_percentile. If no
-        samples have been collected for the given category, then that
-        category name will not be present in the return value."""
+        following keys: mean, 01_0_percentile, 10_0_percentile,
+        50_0_percentile (median), 90_0_percentile, 95_0_percentile,
+        99_0_percentile, 99_9_percentile. If no samples have been collected
+        for the given category, then that category name will not be present
+        in the return value."""
         # note that Amazon's Dynamo paper says they use 99.9% percentile.
         output = {}
         for category in self.latencies:
@@ -835,13 +836,13 @@ class StorageServer(service.MultiService, Referenceable):
             samples.sort()
             count = len(samples)
             stats["mean"] = sum(samples) / count
-            stats["1_percentile"] = samples[int(0.01 * count)]
-            stats["10_percentile"] = samples[int(0.1 * count)]
-            stats["median"] = samples[int(0.5 * count)]
-            stats["90_percentile"] = samples[int(0.9 * count)]
-            stats["95_percentile"] = samples[int(0.95 * count)]
-            stats["99_percentile"] = samples[int(0.99 * count)]
-            stats["999_percentile"] = samples[int(0.999 * count)]
+            stats["01_0_percentile"] = samples[int(0.01 * count)]
+            stats["10_0_percentile"] = samples[int(0.1 * count)]
+            stats["50_0_percentile"] = samples[int(0.5 * count)]
+            stats["90_0_percentile"] = samples[int(0.9 * count)]
+            stats["95_0_percentile"] = samples[int(0.95 * count)]
+            stats["99_0_percentile"] = samples[int(0.99 * count)]
+            stats["99_9_percentile"] = samples[int(0.999 * count)]
             output[category] = stats
         return output
 
index d660caa75de682a68b742950bac12a7933415a01..59004439f9f0de37d4c79cddce42a969a5b5e7c9 100644 (file)
@@ -1150,32 +1150,40 @@ class Stats(unittest.TestCase):
                              sorted(["allocate", "renew", "cancel", "get"]))
         self.failUnlessEqual(len(ss.latencies["allocate"]), 1000)
         self.failUnless(abs(output["allocate"]["mean"] - 9500) < 1)
-        self.failUnless(abs(output["allocate"]["median"] - 9500) < 1)
-        self.failUnless(abs(output["allocate"]["90_percentile"] - 9900) < 1)
-        self.failUnless(abs(output["allocate"]["95_percentile"] - 9950) < 1)
-        self.failUnless(abs(output["allocate"]["99_percentile"] - 9990) < 1)
-        self.failUnless(abs(output["allocate"]["999_percentile"] - 9999) < 1)
+        self.failUnless(abs(output["allocate"]["01_0_percentile"] - 9010) < 1)
+        self.failUnless(abs(output["allocate"]["10_0_percentile"] - 9100) < 1)
+        self.failUnless(abs(output["allocate"]["50_0_percentile"] - 9500) < 1)
+        self.failUnless(abs(output["allocate"]["90_0_percentile"] - 9900) < 1)
+        self.failUnless(abs(output["allocate"]["95_0_percentile"] - 9950) < 1)
+        self.failUnless(abs(output["allocate"]["99_0_percentile"] - 9990) < 1)
+        self.failUnless(abs(output["allocate"]["99_9_percentile"] - 9999) < 1)
 
         self.failUnlessEqual(len(ss.latencies["renew"]), 1000)
         self.failUnless(abs(output["renew"]["mean"] - 500) < 1)
-        self.failUnless(abs(output["renew"]["median"] - 500) < 1)
-        self.failUnless(abs(output["renew"]["90_percentile"] - 900) < 1)
-        self.failUnless(abs(output["renew"]["95_percentile"] - 950) < 1)
-        self.failUnless(abs(output["renew"]["99_percentile"] - 990) < 1)
-        self.failUnless(abs(output["renew"]["999_percentile"] - 999) < 1)
+        self.failUnless(abs(output["renew"]["01_0_percentile"] -  10) < 1)
+        self.failUnless(abs(output["renew"]["10_0_percentile"] - 100) < 1)
+        self.failUnless(abs(output["renew"]["50_0_percentile"] - 500) < 1)
+        self.failUnless(abs(output["renew"]["90_0_percentile"] - 900) < 1)
+        self.failUnless(abs(output["renew"]["95_0_percentile"] - 950) < 1)
+        self.failUnless(abs(output["renew"]["99_0_percentile"] - 990) < 1)
+        self.failUnless(abs(output["renew"]["99_9_percentile"] - 999) < 1)
 
         self.failUnlessEqual(len(ss.latencies["cancel"]), 10)
         self.failUnless(abs(output["cancel"]["mean"] - 9) < 1)
-        self.failUnless(abs(output["cancel"]["median"] - 10) < 1)
-        self.failUnless(abs(output["cancel"]["90_percentile"] - 18) < 1)
-        self.failUnless(abs(output["cancel"]["95_percentile"] - 18) < 1)
-        self.failUnless(abs(output["cancel"]["99_percentile"] - 18) < 1)
-        self.failUnless(abs(output["cancel"]["999_percentile"] - 18) < 1)
+        self.failUnless(abs(output["cancel"]["01_0_percentile"] -  0) < 1)
+        self.failUnless(abs(output["cancel"]["10_0_percentile"] -  2) < 1)
+        self.failUnless(abs(output["cancel"]["50_0_percentile"] - 10) < 1)
+        self.failUnless(abs(output["cancel"]["90_0_percentile"] - 18) < 1)
+        self.failUnless(abs(output["cancel"]["95_0_percentile"] - 18) < 1)
+        self.failUnless(abs(output["cancel"]["99_0_percentile"] - 18) < 1)
+        self.failUnless(abs(output["cancel"]["99_9_percentile"] - 18) < 1)
 
         self.failUnlessEqual(len(ss.latencies["get"]), 1)
         self.failUnless(abs(output["get"]["mean"] - 5) < 1)
-        self.failUnless(abs(output["get"]["median"] - 5) < 1)
-        self.failUnless(abs(output["get"]["90_percentile"] - 5) < 1)
-        self.failUnless(abs(output["get"]["95_percentile"] - 5) < 1)
-        self.failUnless(abs(output["get"]["99_percentile"] - 5) < 1)
-        self.failUnless(abs(output["get"]["999_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["01_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["10_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["50_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["90_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["95_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["99_0_percentile"] - 5) < 1)
+        self.failUnless(abs(output["get"]["99_9_percentile"] - 5) < 1)