Skip to content

Commit 0c80baf

Browse files
rlyerlymeta-codesync[bot]
authored andcommitted
Aggregate statistics across instances
Summary: Aggregate & print stats across all runner instances. Throughput stats are easy - just sum them. Latency & percentile stats are harder because you would need instances to bump 2 sets of counters - one per-instance set and another aggregated set. That's pretty invasive, so instead just print a warning that we don't aggregate latency numbers. Reviewed By: byahn0996 Differential Revision: D90774971 fbshipit-source-id: 4618743a4a2adb1aa785694bf7c352aedba905d1
1 parent 8ef6864 commit 0c80baf

8 files changed

Lines changed: 367 additions & 164 deletions

File tree

cachelib/allocator/memory/MemoryAllocatorStats.h

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <folly/container/F14Map.h>
2020

2121
#include <set>
22-
#include <unordered_map>
2322

2423
#include "cachelib/allocator/memory/Slab.h"
2524

@@ -29,25 +28,25 @@ namespace cachelib {
2928
// structure to query the stats corresponding to an AllocationClass.
3029
struct ACStats {
3130
// the allocation size for this allocation class
32-
uint32_t allocSize;
31+
uint32_t allocSize{0};
3332

3433
// number of allocations per slab
35-
unsigned long long allocsPerSlab;
34+
unsigned long long allocsPerSlab{0};
3635

3736
// number of slabs that are currently used for active allocations.
38-
unsigned long long usedSlabs;
37+
unsigned long long usedSlabs{0};
3938

4039
// number of free slabs in this allocation class.
41-
unsigned long long freeSlabs;
40+
unsigned long long freeSlabs{0};
4241

4342
// number of freed allocations in this allocation class.
44-
unsigned long long freeAllocs;
43+
unsigned long long freeAllocs{0};
4544

4645
// number of active allocations in this class.
47-
unsigned long long activeAllocs;
46+
unsigned long long activeAllocs{0};
4847

4948
// true if the allocation class is full.
50-
bool full;
49+
bool full{false};
5150

5251
constexpr unsigned long long totalSlabs() const noexcept {
5352
return freeSlabs + usedSlabs;
@@ -56,6 +55,21 @@ struct ACStats {
5655
constexpr size_t getTotalFreeMemory() const noexcept {
5756
return Slab::kSize * freeSlabs + freeAllocs * allocSize;
5857
}
58+
59+
ACStats& operator+=(const ACStats& other) {
60+
if (allocSize != other.allocSize) {
61+
XDCHECK(allocSize == 0 && allocsPerSlab == 0);
62+
// this is an empty ACStats object, copy the other one
63+
allocSize = other.allocSize;
64+
allocsPerSlab = other.allocsPerSlab;
65+
}
66+
usedSlabs += other.usedSlabs;
67+
freeSlabs += other.freeSlabs;
68+
freeAllocs += other.freeAllocs;
69+
activeAllocs += other.activeAllocs;
70+
full |= other.full;
71+
return *this;
72+
}
5973
};
6074

6175
// structure to query stats corresponding to a MemoryPool

0 commit comments

Comments
 (0)