@@ -96,7 +96,8 @@ struct Stats {
9696 uint64_t invalidDestructorCount{0 };
9797 int64_t unDestructedItemCount{0 };
9898
99- std::map<TierId, std::map<PoolId, std::map<ClassId, AllocationClassBaseStat>>> allocationClassStats;
99+ std::map<TierId, std::map<PoolId, std::map<ClassId, AllocationClassBaseStat>>>
100+ allocationClassStats;
100101
101102 std::vector<double > slabsApproxFreePercentages;
102103
@@ -122,7 +123,9 @@ struct Stats {
122123
123124 if (FLAGS_report_memory_usage_stats) {
124125 for (TierId tid = 0 ; tid < slabsApproxFreePercentages.size (); tid++) {
125- out << folly::sformat (" tid{:2} free slabs : {:.2f}%" , tid, slabsApproxFreePercentages[tid]) << std::endl;
126+ out << folly::sformat (" tid{:2} free slabs : {:.2f}%" , tid,
127+ slabsApproxFreePercentages[tid])
128+ << std::endl;
126129 }
127130
128131 auto formatMemory = [](size_t bytes) -> std::tuple<std::string, double > {
@@ -142,26 +145,25 @@ struct Stats {
142145 };
143146
144147 auto foreachAC = [&](auto cb) {
145- for (auto & tidStats : allocationClassStats) {
146- for (auto & pidStat : tidStats.second ) {
147- for (auto & cidStat : pidStat.second ) {
148+ for (auto & tidStats : allocationClassStats) {
149+ for (auto & pidStat : tidStats.second ) {
150+ for (auto & cidStat : pidStat.second ) {
148151 cb (tidStats.first , pidStat.first , cidStat.first , cidStat.second );
149152 }
150153 }
151154 }
152155 };
153156
154- foreachAC ([&](auto tid, auto pid, auto cid, auto stats){
157+ foreachAC ([&](auto tid, auto pid, auto cid, auto stats) {
155158 auto [allocSizeSuffix, allocSize] = formatMemory (stats.allocSize );
156159 auto [memorySizeSuffix, memorySize] = formatMemory (stats.memorySize );
157- out << folly::sformat (" tid{:2} pid{:2} cid{:4} {:8.2f}{} memorySize: {:8.2f}{}" ,
158- tid, pid, cid, allocSize, allocSizeSuffix, memorySize, memorySizeSuffix) << std::endl;
159- });
160-
161- foreachAC ([&](auto tid, auto pid, auto cid, auto stats){
162- auto [allocSizeSuffix, allocSize] = formatMemory (stats.allocSize );
163- out << folly::sformat (" tid{:2} pid{:2} cid{:4} {:8.2f}{} free: {:4.2f}%" ,
164- tid, pid, cid, allocSize, allocSizeSuffix, stats.approxFreePercent ) << std::endl;
160+ out << folly::sformat (
161+ " tid{:2} pid{:2} cid{:4} {:8.2f}{} memorySize:{:8.2f}{} "
162+ " free:{:4.2f}% rollingAvgLatency:{:8.2f}ns" ,
163+ tid, pid, cid, allocSize, allocSizeSuffix, memorySize,
164+ memorySizeSuffix, stats.approxFreePercent ,
165+ stats.allocLatencyNs .estimate ())
166+ << std::endl;
165167 });
166168 }
167169
0 commit comments