@@ -61,6 +61,12 @@ FilterMemProfile("filter-mem-profile",
61
61
cl::init(true ),
62
62
cl::cat(AggregatorCategory));
63
63
64
+ static cl::opt<bool > ParseMemProfile (
65
+ " parse-mem-profile" ,
66
+ cl::desc (" enable memory profile parsing if it's present in the input data, "
67
+ " on by default unless `--itrace` is set." ),
68
+ cl::init(true ), cl::cat(AggregatorCategory));
69
+
64
70
static cl::opt<unsigned long long >
65
71
FilterPID (" pid" ,
66
72
cl::desc (" only use samples from process with specified PID" ),
@@ -181,6 +187,10 @@ void DataAggregator::start() {
181
187
" script -F pid,event,ip" ,
182
188
/* Wait = */ false );
183
189
} else if (!opts::ITraceAggregation.empty ()) {
190
+ // Disable parsing memory profile from trace data, unless requested by user.
191
+ if (!opts::ParseMemProfile.getNumOccurrences ())
192
+ opts::ParseMemProfile = false ;
193
+
184
194
std::string ItracePerfScriptArgs = llvm::formatv (
185
195
" script -F pid,brstack --itrace={0}" , opts::ITraceAggregation);
186
196
launchPerfProcess (" branch events with itrace" , MainEventsPPI,
@@ -191,12 +201,9 @@ void DataAggregator::start() {
191
201
/* Wait = */ false );
192
202
}
193
203
194
- // Note: we launch script for mem events regardless of the option, as the
195
- // command fails fairly fast if mem events were not collected.
196
- launchPerfProcess (" mem events" ,
197
- MemEventsPPI,
198
- " script -F pid,event,addr,ip" ,
199
- /* Wait = */ false );
204
+ if (opts::ParseMemProfile)
205
+ launchPerfProcess (" mem events" , MemEventsPPI, " script -F pid,event,addr,ip" ,
206
+ /* Wait = */ false );
200
207
201
208
launchPerfProcess (" process events" , MMapEventsPPI,
202
209
" script --show-mmap-events --no-itrace" ,
@@ -217,7 +224,8 @@ void DataAggregator::abort() {
217
224
sys::Wait (TaskEventsPPI.PI , 1 , &Error);
218
225
sys::Wait (MMapEventsPPI.PI , 1 , &Error);
219
226
sys::Wait (MainEventsPPI.PI , 1 , &Error);
220
- sys::Wait (MemEventsPPI.PI , 1 , &Error);
227
+ if (opts::ParseMemProfile)
228
+ sys::Wait (MemEventsPPI.PI , 1 , &Error);
221
229
222
230
deleteTempFiles ();
223
231
@@ -506,7 +514,8 @@ Error DataAggregator::preprocessProfile(BinaryContext &BC) {
506
514
errs () << " PERF2BOLT: failed to parse samples\n " ;
507
515
508
516
// Special handling for memory events
509
- if (!prepareToParse (" mem events" , MemEventsPPI, MemEventsErrorCallback))
517
+ if (opts::ParseMemProfile &&
518
+ !prepareToParse (" mem events" , MemEventsPPI, MemEventsErrorCallback))
510
519
if (const std::error_code EC = parseMemEvents ())
511
520
errs () << " PERF2BOLT: failed to parse memory events: " << EC.message ()
512
521
<< ' \n ' ;
0 commit comments