From: Brian Warner Date: Sat, 12 Jul 2008 04:51:02 +0000 (-0700) Subject: storage: rename the latency key names so they sort properly X-Git-Url: https://git.rkrishnan.org/pf/content/%22file:/%5B%5E?a=commitdiff_plain;h=c46f5bc634613f1c76d1c76237199b3e1c787ff9;p=tahoe-lafs%2Ftahoe-lafs.git storage: rename the latency key names so they sort properly --- diff --git a/src/allmydata/storage.py b/src/allmydata/storage.py index 775c47e3..4029d966 100644 --- a/src/allmydata/storage.py +++ b/src/allmydata/storage.py @@ -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 diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index d660caa7..59004439 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -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)