Skip to content

Commit 339f24c

Browse files
stepanchegfacebook-github-bot
authored andcommitted
Rename ProfileMode::HeapSummary -> HeapSummaryAllocated
Summary: Make it choice between `HeapSummaryRetained` and `HeapSummaryAllocated` more explicit. Reviewed By: bobyangyf Differential Revision: D38646893 fbshipit-source-id: 8b77aa54f01f06cc28000aa2c42a1f84f9b1c023
1 parent fef39f0 commit 339f24c

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

starlark/src/eval/runtime/evaluator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ impl<'v, 'a> Evaluator<'v, 'a> {
231231
self.profile_or_instrumentation_mode = ProfileOrInstrumentationMode::Profile(mode.dupe());
232232

233233
match mode {
234-
ProfileMode::HeapSummary
235-
| ProfileMode::HeapFlame
234+
ProfileMode::HeapSummaryAllocated
235+
| ProfileMode::HeapFlameAllocated
236236
| ProfileMode::HeapSummaryRetained
237237
| ProfileMode::HeapFlameRetained => {
238238
self.heap_profile.enable();
@@ -287,9 +287,9 @@ impl<'v, 'a> Evaluator<'v, 'a> {
287287
ProfileMode::Statement => {
288288
self.before_stmt.instrument = true;
289289
}
290-
ProfileMode::HeapSummary
290+
ProfileMode::HeapSummaryAllocated
291291
| ProfileMode::HeapSummaryRetained
292-
| ProfileMode::HeapFlame
292+
| ProfileMode::HeapFlameAllocated
293293
| ProfileMode::HeapFlameRetained
294294
| ProfileMode::TimeFlame => {
295295
self.heap_or_flame_profile = true;
@@ -322,11 +322,11 @@ impl<'v, 'a> Evaluator<'v, 'a> {
322322
};
323323
self.profile_or_instrumentation_mode = ProfileOrInstrumentationMode::Collected;
324324
match mode {
325-
ProfileMode::HeapSummary => self
325+
ProfileMode::HeapSummaryAllocated => self
326326
.heap_profile
327327
.gen(self.heap(), HeapProfileFormat::Summary)
328328
.ok_or_else(|| EvaluatorError::HeapProfilingNotEnabled.into()),
329-
ProfileMode::HeapFlame => self
329+
ProfileMode::HeapFlameAllocated => self
330330
.heap_profile
331331
.gen(self.heap(), HeapProfileFormat::FlameGraph)
332332
.ok_or_else(|| EvaluatorError::HeapProfilingNotEnabled.into()),

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ impl HeapProfile {
7878

7979
fn write_flame_heap_profile(heap: &Heap) -> ProfileData {
8080
let stacks = AggregateHeapProfileInfo::collect(heap, None);
81-
ProfileData::new(ProfileMode::HeapFlame, stacks.gen_flame_graph())
81+
ProfileData::new(ProfileMode::HeapFlameAllocated, stacks.gen_flame_graph())
8282
}
8383

8484
fn write_summarized_heap_profile(heap: &Heap) -> ProfileData {
8585
let stacks = AggregateHeapProfileInfo::collect(heap, None);
86-
ProfileData::new(ProfileMode::HeapSummary, stacks.gen_summary_csv())
86+
ProfileData::new(ProfileMode::HeapSummaryAllocated, stacks.gen_summary_csv())
8787
}
8888
}
8989

@@ -115,7 +115,8 @@ f
115115
let globals = Globals::standard();
116116
let module = Module::new();
117117
let mut eval = Evaluator::new(&module);
118-
eval.enable_profile(&ProfileMode::HeapSummary).unwrap();
118+
eval.enable_profile(&ProfileMode::HeapSummaryAllocated)
119+
.unwrap();
119120
let f = eval.eval_module(ast, &globals)?;
120121
// first check module profiling works
121122
HeapProfile::write_summarized_heap_profile(module.heap());
@@ -124,7 +125,8 @@ f
124125
// second check function profiling works
125126
let module = Module::new();
126127
let mut eval = Evaluator::new(&module);
127-
eval.enable_profile(&ProfileMode::HeapSummary).unwrap();
128+
eval.enable_profile(&ProfileMode::HeapSummaryAllocated)
129+
.unwrap();
128130
eval.eval_function(f, &[Value::new_int(100)], &[])?;
129131
HeapProfile::write_summarized_heap_profile(module.heap());
130132
HeapProfile::write_flame_heap_profile(module.heap());
@@ -133,7 +135,8 @@ f
133135
let module = Module::new();
134136
let mut eval = Evaluator::new(&module);
135137
module.heap().alloc("Thing that goes before");
136-
eval.enable_profile(&ProfileMode::HeapSummary).unwrap();
138+
eval.enable_profile(&ProfileMode::HeapSummaryAllocated)
139+
.unwrap();
137140
eval.eval_function(f, &[Value::new_int(100)], &[])?;
138141
module.heap().alloc("Thing that goes after");
139142
HeapProfile::write_summarized_heap_profile(module.heap());

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ pub enum ProfileMode {
3737
/// The heap profile mode provides information about the time spent in each function and allocations
3838
/// performed by each function. Enabling this mode the side effect of disabling garbage-collection.
3939
/// This profiling mode is the recommended one.
40-
HeapSummary,
40+
HeapSummaryAllocated,
4141
/// Like heap summary, but information about retained memory after module is frozen.
4242
HeapSummaryRetained,
4343
/// Like heap profile, but writes output comparible with
4444
/// [flamegraph.pl](https://github.com/brendangregg/FlameGraph/blob/master/flamegraph.pl).
45-
HeapFlame,
45+
HeapFlameAllocated,
4646
/// Like heap flame, but information about retained memory after module is frozen.
4747
HeapFlameRetained,
4848
/// The statement profile mode provides information about time spent in each statement.
@@ -67,9 +67,9 @@ impl Display for ProfileMode {
6767
impl ProfileMode {
6868
fn name(&self) -> &str {
6969
match self {
70-
ProfileMode::HeapSummary => "heap-summary",
70+
ProfileMode::HeapSummaryAllocated => "heap-summary-allocated",
7171
ProfileMode::HeapSummaryRetained => "heap-summary-retained",
72-
ProfileMode::HeapFlame => "heap-flame",
72+
ProfileMode::HeapFlameAllocated => "heap-flame-allocated",
7373
ProfileMode::HeapFlameRetained => "heap-flame-retained",
7474
ProfileMode::Statement => "statement",
7575
ProfileMode::Bytecode => "bytecode",
@@ -85,9 +85,9 @@ impl FromStr for ProfileMode {
8585

8686
fn from_str(s: &str) -> Result<Self, Self::Err> {
8787
for mode in [
88-
ProfileMode::HeapSummary,
88+
ProfileMode::HeapSummaryAllocated,
8989
ProfileMode::HeapSummaryRetained,
90-
ProfileMode::HeapFlame,
90+
ProfileMode::HeapFlameAllocated,
9191
ProfileMode::HeapFlameRetained,
9292
ProfileMode::Statement,
9393
ProfileMode::Bytecode,

starlark/src/values/layout/heap/profile/summary.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ _ignore = str([1]) # allocate a string in non_drop
200200
let globals = Globals::standard();
201201
let module = Module::new();
202202
let mut eval = Evaluator::new(&module);
203-
eval.enable_profile(&ProfileMode::HeapSummary).unwrap();
203+
eval.enable_profile(&ProfileMode::HeapSummaryAllocated)
204+
.unwrap();
204205

205206
eval.eval_module(ast, &globals).unwrap();
206207

0 commit comments

Comments
 (0)