@@ -318,20 +318,21 @@ ProfilerStartedEvent initProfiler(
318
318
boolean tracerEnabled ,
319
319
ExtendedEventHandler eventHandler ,
320
320
BlazeWorkspace workspace ,
321
- CommonCommandOptions options ,
322
- BuildEventProtocolOptions bepOptions ,
321
+ OptionsProvider options ,
323
322
CommandEnvironment env ,
324
323
long execStartTimeNanos ,
325
324
long waitTimeInMs ) {
325
+ BuildEventProtocolOptions bepOptions = options .getOptions (BuildEventProtocolOptions .class );
326
+ CommonCommandOptions commandOptions = options .getOptions (CommonCommandOptions .class );
326
327
OutputStream out = null ;
327
- boolean recordFullProfilerData = options .recordFullProfilerData ;
328
+ boolean recordFullProfilerData = commandOptions .recordFullProfilerData ;
328
329
ImmutableSet .Builder <ProfilerTask > profiledTasksBuilder = ImmutableSet .builder ();
329
330
Profiler .Format format = Format .JSON_TRACE_FILE_FORMAT ;
330
331
Path profilePath = null ;
331
332
InstrumentationOutput profile = null ;
332
333
try {
333
334
if (tracerEnabled ) {
334
- if (options .profilePath == null ) {
335
+ if (commandOptions .profilePath == null ) {
335
336
String profileName = "command.profile.gz" ;
336
337
format = Format .JSON_TRACE_FILE_COMPRESSED_FORMAT ;
337
338
if (bepOptions != null && bepOptions .streamingLogFileUploads ) {
@@ -354,10 +355,10 @@ ProfilerStartedEvent initProfiler(
354
355
}
355
356
} else {
356
357
format =
357
- options .profilePath .toString ().endsWith (".gz" )
358
+ commandOptions .profilePath .toString ().endsWith (".gz" )
358
359
? Format .JSON_TRACE_FILE_COMPRESSED_FORMAT
359
360
: Format .JSON_TRACE_FILE_FORMAT ;
360
- profilePath = workspace .getWorkspace ().getRelative (options .profilePath );
361
+ profilePath = workspace .getWorkspace ().getRelative (commandOptions .profilePath );
361
362
profile =
362
363
instrumentationOutputFactory
363
364
.createLocalInstrumentationOutputBuilder ()
@@ -379,11 +380,11 @@ ProfilerStartedEvent initProfiler(
379
380
profiledTasksBuilder .add (profilerTask );
380
381
}
381
382
}
382
- profiledTasksBuilder .addAll (options .additionalProfileTasks );
383
- if (options .recordFullProfilerData ) {
383
+ profiledTasksBuilder .addAll (commandOptions .additionalProfileTasks );
384
+ if (commandOptions .recordFullProfilerData ) {
384
385
profiledTasksBuilder .addAll (EnumSet .allOf (ProfilerTask .class ));
385
386
}
386
- } else if (options .alwaysProfileSlowOperations ) {
387
+ } else if (commandOptions .alwaysProfileSlowOperations ) {
387
388
recordFullProfilerData = false ;
388
389
out = null ;
389
390
for (ProfilerTask profilerTask : ProfilerTask .values ()) {
@@ -394,7 +395,7 @@ ProfilerStartedEvent initProfiler(
394
395
}
395
396
ImmutableSet <ProfilerTask > profiledTasks = profiledTasksBuilder .build ();
396
397
if (!profiledTasks .isEmpty ()) {
397
- if (options .slimProfile && options .includePrimaryOutput ) {
398
+ if (commandOptions .slimProfile && commandOptions .includePrimaryOutput ) {
398
399
eventHandler .handle (
399
400
Event .warn (
400
401
"Enabling both --slim_profile and"
@@ -415,45 +416,45 @@ ProfilerStartedEvent initProfiler(
415
416
recordFullProfilerData ,
416
417
clock ,
417
418
execStartTimeNanos ,
418
- options .slimProfile ,
419
- options .includePrimaryOutput ,
420
- options .profileIncludeTargetLabel ,
421
- options .alwaysProfileSlowOperations ,
419
+ commandOptions .slimProfile ,
420
+ commandOptions .includePrimaryOutput ,
421
+ commandOptions .profileIncludeTargetLabel ,
422
+ commandOptions .alwaysProfileSlowOperations ,
422
423
new CollectLocalResourceUsage (
423
424
bugReporter ,
424
425
workerProcessMetricsCollector ,
425
426
env .getLocalResourceManager (),
426
- options .collectSkyframeCounts
427
+ commandOptions .collectSkyframeCounts
427
428
? env .getSkyframeExecutor ().getEvaluator ().getInMemoryGraph ()
428
429
: null ,
429
- options .collectWorkerDataInProfiler ,
430
- options .collectLoadAverageInProfiler ,
431
- options .collectSystemNetworkUsage ,
432
- options .collectResourceEstimation ,
433
- options .collectPressureStallIndicators ,
434
- options .collectSkyframeCounts ));
430
+ commandOptions .collectWorkerDataInProfiler ,
431
+ commandOptions .collectLoadAverageInProfiler ,
432
+ commandOptions .collectSystemNetworkUsage ,
433
+ commandOptions .collectResourceEstimation ,
434
+ commandOptions .collectPressureStallIndicators ,
435
+ commandOptions .collectSkyframeCounts ));
435
436
// Instead of logEvent() we're calling the low level function to pass the timings we took in
436
437
// the launcher. We're setting the INIT phase marker so that it follows immediately the
437
438
// LAUNCH phase.
438
- long startupTimeNanos = options .startupTime * 1000000L ;
439
+ long startupTimeNanos = commandOptions .startupTime * 1000000L ;
439
440
long waitTimeNanos = waitTimeInMs * 1000000L ;
440
441
long clientStartTimeNanos = execStartTimeNanos - startupTimeNanos - waitTimeNanos ;
441
442
profiler .logSimpleTaskDuration (
442
443
clientStartTimeNanos ,
443
444
Duration .ofNanos (startupTimeNanos ),
444
445
ProfilerTask .PHASE ,
445
446
ProfilePhase .LAUNCH .description );
446
- if (options .extractDataTime > 0 ) {
447
+ if (commandOptions .extractDataTime > 0 ) {
447
448
profiler .logSimpleTaskDuration (
448
449
clientStartTimeNanos ,
449
- Duration .ofMillis (options .extractDataTime ),
450
+ Duration .ofMillis (commandOptions .extractDataTime ),
450
451
ProfilerTask .PHASE ,
451
452
"Extracting Bazel binary" );
452
453
}
453
- if (options .waitTime > 0 ) {
454
+ if (commandOptions .waitTime > 0 ) {
454
455
profiler .logSimpleTaskDuration (
455
456
clientStartTimeNanos ,
456
- Duration .ofMillis (options .waitTime ),
457
+ Duration .ofMillis (commandOptions .waitTime ),
457
458
ProfilerTask .PHASE ,
458
459
"Blocking on busy Bazel server (in client)" );
459
460
}
0 commit comments