| 664 | } |
| 665 | |
| 666 | void AggregatedRuntimeProfile::UpdateSummaryStatsFromInstances( |
| 667 | const TRuntimeProfileNode& node, int start_idx, ObjectPool* pool) { |
| 668 | lock_guard<SpinLock> l(summary_stats_map_lock_); |
| 669 | DCHECK(node.__isset.aggregated); |
| 670 | const TAggregatedRuntimeProfileNode& agg_node = node.aggregated; |
| 671 | for (const TAggSummaryStatsCounter& tcounter : agg_node.summary_stats_counters) { |
| 672 | DCHECK_GT(num_input_profiles_, 0); |
| 673 | DCHECK_LE(start_idx + tcounter.has_value.size(), num_input_profiles_); |
| 674 | auto& entry = summary_stats_map_[tcounter.name]; |
| 675 | vector<SummaryStatsCounter*>& instance_counters = entry.second; |
| 676 | if (instance_counters.empty()) { |
| 677 | instance_counters.resize(num_input_profiles_); |
| 678 | entry.first = tcounter.unit; |
| 679 | } else { |
| 680 | DCHECK_EQ(entry.first, tcounter.unit) << "Unit must be consistent"; |
| 681 | } |
| 682 | |
| 683 | TSummaryStatsCounter tmp_counter; |
| 684 | tmp_counter.name = tcounter.name; |
| 685 | tmp_counter.unit = tcounter.unit; |
| 686 | for (int i = 0; i < tcounter.has_value.size(); ++i) { |
| 687 | if (!tcounter.has_value[i]) continue; |
| 688 | int idx = start_idx + i; |
| 689 | // Get the counter with the same name. Create one if it doesn't exist. |
| 690 | if (instance_counters[idx] == nullptr) { |
| 691 | instance_counters[idx] = pool->Add(new SummaryStatsCounter(tcounter.unit)); |
| 692 | } |
| 693 | // Overwrite the previous value with the new value. |
| 694 | tmp_counter.sum = tcounter.sum[i]; |
| 695 | tmp_counter.total_num_values = tcounter.total_num_values[i]; |
| 696 | tmp_counter.min_value = tcounter.min_value[i]; |
| 697 | tmp_counter.max_value = tcounter.max_value[i]; |
| 698 | instance_counters[idx]->SetStats(tmp_counter); |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | void AggregatedRuntimeProfile::UpdateEventSequencesFromInstances( |
| 704 | const TRuntimeProfileNode& node, int start_idx, ObjectPool* pool) { |