Skip to content

Commit 5b3c52c

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Merge AggregateHeapProfileInfo in ProfileData
Reviewed By: bobyangyf Differential Revision: D38681779 fbshipit-source-id: d4bca3ded3b53b85634dd14ac114a6a596575e81
1 parent d96c78f commit 5b3c52c

File tree

1 file changed

+33
-0
lines changed
  • starlark/src/eval/runtime/profile

1 file changed

+33
-0
lines changed

starlark/src/eval/runtime/profile/data.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ impl ProfileData {
125125
let profile = BcPairsProfileData::merge(profiles);
126126
ProfileDataImpl::BcPairs(profile)
127127
}
128+
ProfileMode::HeapSummaryAllocated
129+
| ProfileMode::HeapSummaryRetained
130+
| ProfileMode::HeapFlameAllocated
131+
| ProfileMode::HeapFlameRetained => {
132+
let profiles = profiles.try_map(|p| match &p.profile {
133+
ProfileDataImpl::AggregateHeapProfileInfo(profile) => Ok(&**profile),
134+
_ => Err(ProfileDataError::ProfileDataNotConsistent),
135+
})?;
136+
let profile = AggregateHeapProfileInfo::merge(profiles);
137+
ProfileDataImpl::AggregateHeapProfileInfo(box profile)
138+
}
128139
profile_mode => {
129140
return Err(ProfileDataError::MergeNotImplemented(profile_mode.dupe()).into());
130141
}
@@ -138,11 +149,14 @@ impl ProfileData {
138149

139150
#[cfg(test)]
140151
mod tests {
152+
use gazebo::dupe::Dupe;
153+
141154
use crate::eval::runtime::profile::bc::BcPairsProfileData;
142155
use crate::eval::runtime::profile::bc::BcProfileData;
143156
use crate::eval::runtime::profile::data::ProfileDataImpl;
144157
use crate::eval::ProfileData;
145158
use crate::eval::ProfileMode;
159+
use crate::values::AggregateHeapProfileInfo;
146160

147161
#[test]
148162
fn merge_bc() {
@@ -163,4 +177,23 @@ mod tests {
163177
// Smoke.
164178
ProfileData::merge([&profile, &profile]).unwrap();
165179
}
180+
181+
#[test]
182+
fn merge_aggregated_heap_profile() {
183+
for profile_mode in [
184+
ProfileMode::HeapFlameRetained,
185+
ProfileMode::HeapFlameAllocated,
186+
ProfileMode::HeapSummaryRetained,
187+
ProfileMode::HeapSummaryAllocated,
188+
] {
189+
let profile = ProfileData {
190+
profile_mode: profile_mode.dupe(),
191+
profile: ProfileDataImpl::AggregateHeapProfileInfo(
192+
box AggregateHeapProfileInfo::default(),
193+
),
194+
};
195+
// Smoke.
196+
ProfileData::merge([&profile, &profile]).unwrap();
197+
}
198+
}
166199
}

0 commit comments

Comments
 (0)