4242import java .util .Map ;
4343import java .util .UUID ;
4444import java .util .concurrent .TimeUnit ;
45- import java .util .concurrent .atomic .AtomicInteger ;
4645import java .util .concurrent .atomic .AtomicReference ;
4746import java .util .function .Supplier ;
4847import java .util .zip .GZIPOutputStream ;
@@ -129,33 +128,26 @@ public ProfilerTask getType() {
129128 static class TaskData implements TraceData {
130129 final long threadId ;
131130 final long startTimeNanos ;
132- final int id ;
133131 final ProfilerTask type ;
134132 final MnemonicData mnemonic ;
135133 final String description ;
136134
137135 long duration ;
138136
139137 TaskData (
140- int id ,
141- long startTimeNanos ,
142- ProfilerTask eventType ,
143- MnemonicData mnemonic ,
144- String description ) {
145- this .id = id ;
138+ long startTimeNanos , ProfilerTask eventType , MnemonicData mnemonic , String description ) {
146139 this .threadId = Thread .currentThread ().getId ();
147140 this .startTimeNanos = startTimeNanos ;
148141 this .type = eventType ;
149142 this .mnemonic = mnemonic ;
150143 this .description = Preconditions .checkNotNull (description );
151144 }
152145
153- TaskData (int id , long startTimeNanos , ProfilerTask eventType , String description ) {
154- this (id , startTimeNanos , eventType , MnemonicData .getEmptyMnemonic (), description );
146+ TaskData (long startTimeNanos , ProfilerTask eventType , String description ) {
147+ this (startTimeNanos , eventType , MnemonicData .getEmptyMnemonic (), description );
155148 }
156149
157150 TaskData (long threadId , long startTimeNanos , long duration , String description ) {
158- this .id = -1 ;
159151 this .type = ProfilerTask .UNKNOWN ;
160152 this .mnemonic = MnemonicData .getEmptyMnemonic ();
161153 this .threadId = threadId ;
@@ -166,7 +158,7 @@ static class TaskData implements TraceData {
166158
167159 @ Override
168160 public String toString () {
169- return "Thread " + threadId + ", task " + id + ", type " + type + ", " + description ;
161+ return "Thread " + threadId + ", type " + type + ", " + description ;
170162 }
171163
172164 @ Override
@@ -239,14 +231,13 @@ static final class ActionTaskData extends TaskData {
239231 @ Nullable final String targetLabel ;
240232
241233 ActionTaskData (
242- int id ,
243234 long startTimeNanos ,
244235 ProfilerTask eventType ,
245236 MnemonicData mnemonic ,
246237 String description ,
247238 @ Nullable String primaryOutputPath ,
248239 @ Nullable String targetLabel ) {
249- super (id , startTimeNanos , eventType , mnemonic , description );
240+ super (startTimeNanos , eventType , mnemonic , description );
250241 this .primaryOutputPath = primaryOutputPath ;
251242 this .targetLabel = targetLabel ;
252243 }
@@ -313,9 +304,6 @@ Iterable<SlowTask> getSlowestTasks() {
313304 private volatile boolean recordAllDurations = false ;
314305 private Duration profileCpuStartTime ;
315306
316- /** This counter provides a unique id for every task, used to provide a parent/child relation. */
317- private AtomicInteger taskId = new AtomicInteger ();
318-
319307 /**
320308 * The reference to the current writer, if any. If the referenced writer is null, then disk writes
321309 * are disabled. This can happen when slowest task recording is enabled.
@@ -467,10 +455,8 @@ public synchronized void start(
467455 this .collectTaskHistograms = collectTaskHistograms ;
468456 this .includePrimaryOutput = includePrimaryOutput ;
469457 this .includeTargetLabel = includeTargetLabel ;
470-
471- // Reset state for the new profiling session.
472- taskId .set (0 );
473458 this .recordAllDurations = recordAllDurations ;
459+
474460 JsonTraceFileWriter writer = null ;
475461 if (stream != null && format != null ) {
476462 switch (format ) {
@@ -642,7 +628,7 @@ private void logTask(long startTimeNanos, long duration, ProfilerTask type, Stri
642628 // #clear.
643629 JsonTraceFileWriter currentWriter = writerRef .get ();
644630 if (wasTaskSlowEnoughToRecord (type , duration )) {
645- TaskData data = new TaskData (taskId . incrementAndGet (), startTimeNanos , type , description );
631+ TaskData data = new TaskData (startTimeNanos , type , description );
646632 data .duration = duration ;
647633 if (currentWriter != null ) {
648634 currentWriter .enqueue (data );
@@ -716,12 +702,7 @@ void logEvent(ProfilerTask type, String description) {
716702 }
717703
718704 private SilentCloseable reallyProfile (ProfilerTask type , String description ) {
719- // ProfilerInfo.allTasksById is supposed to be an id -> Task map, but it is in fact a List,
720- // which means that we cannot drop tasks to which we had already assigned ids. Therefore,
721- // non-leaf tasks must not have a minimum duration. However, we don't quite consistently
722- // enforce this, and Blaze only works because we happen not to add child tasks to those parent
723- // tasks that have a minimum duration.
724- TaskData taskData = new TaskData (taskId .incrementAndGet (), clock .nanoTime (), type , description );
705+ TaskData taskData = new TaskData (clock .nanoTime (), type , description );
725706 return () -> completeTask (taskData );
726707 }
727708
@@ -797,7 +778,6 @@ public SilentCloseable profileAction(
797778 if (isActive () && isProfiling (type )) {
798779 TaskData taskData =
799780 new ActionTaskData (
800- taskId .incrementAndGet (),
801781 clock .nanoTime (),
802782 type ,
803783 new MnemonicData (mnemonic ),
0 commit comments