@@ -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 > {
@@ -146,26 +149,25 @@ struct Stats {
146149 };
147150
148151 auto foreachAC = [&](auto cb) {
149- for (auto & tidStats : allocationClassStats) {
150- for (auto & pidStat : tidStats.second ) {
151- for (auto & cidStat : pidStat.second ) {
152+ for (auto & tidStats : allocationClassStats) {
153+ for (auto & pidStat : tidStats.second ) {
154+ for (auto & cidStat : pidStat.second ) {
152155 cb (tidStats.first , pidStat.first , cidStat.first , cidStat.second );
153156 }
154157 }
155158 }
156159 };
157160
158- foreachAC ([&](auto tid, auto pid, auto cid, auto stats){
161+ foreachAC ([&](auto tid, auto pid, auto cid, auto stats) {
159162 auto [allocSizeSuffix, allocSize] = formatMemory (stats.allocSize );
160163 auto [memorySizeSuffix, memorySize] = formatMemory (stats.memorySize );
161- out << folly::sformat (" tid{:2} pid{:2} cid{:4} {:8.2f}{} memorySize: {:8.2f}{}" ,
162- tid, pid, cid, allocSize, allocSizeSuffix, memorySize, memorySizeSuffix) << std::endl;
163- });
164-
165- foreachAC ([&](auto tid, auto pid, auto cid, auto stats){
166- auto [allocSizeSuffix, allocSize] = formatMemory (stats.allocSize );
167- out << folly::sformat (" tid{:2} pid{:2} cid{:4} {:8.2f}{} free: {:4.2f}%" ,
168- tid, pid, cid, allocSize, allocSizeSuffix, stats.approxFreePercent ) << std::endl;
164+ out << folly::sformat (
165+ " tid{:2} pid{:2} cid{:4} {:8.2f}{} memorySize:{:8.2f}{} "
166+ " free:{:4.2f}% rollingAvgAllocLatency:{:8.2f}ns" ,
167+ tid, pid, cid, allocSize, allocSizeSuffix, memorySize,
168+ memorySizeSuffix, stats.approxFreePercent ,
169+ stats.allocLatencyNs .estimate ())
170+ << std::endl;
169171 });
170172 }
171173
0 commit comments