]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/trace: use different colors for tasks
authorHana Kim <hakim@google.com>
Wed, 25 Apr 2018 16:50:31 +0000 (12:50 -0400)
committerHyang-Ah Hana Kim <hyangah@gmail.com>
Sun, 29 Apr 2018 18:14:22 +0000 (18:14 +0000)
and assign the same colors for spans belong to the tasks
(sadly, the trace viewer will change the saturation/ligthness
for asynchronous slices so exact color mapping is impossible.
But I hope they are not too far from each other)

Change-Id: Idaaf0828a1e0dac8012d336dcefa1c6572ddca2e
Reviewed-on: https://go-review.googlesource.com/109338
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
src/cmd/trace/trace.go

index 0972e1d0479ef8620f6d053fd376cbd04482f621..7a61d5b412ad7174a3d731a3fd2fb04fc9011aa3 100644 (file)
@@ -900,7 +900,7 @@ func (ctx *traceContext) emitTask(task *taskDesc, sortIndex int) {
                Dur:   durationUsec,
                Pid:   tasksSection,
                Tid:   taskRow,
-               Cname: colorSeafoamGreen,
+               Cname: pickTaskColor(task.id),
        }
        targ := TaskArg{ID: task.id}
        if task.create != nil {
@@ -946,7 +946,7 @@ func (ctx *traceContext) emitRegion(s regionDesc) {
                Tid:      s.G, // only in goroutine-oriented view
                ID:       uint64(regionID),
                Scope:    scopeID,
-               Cname:    colorDeepMagenta,
+               Cname:    pickTaskColor(s.TaskID),
        }
        if s.Start != nil {
                sl0.Stack = ctx.stack(s.Start.Stk)
@@ -961,7 +961,7 @@ func (ctx *traceContext) emitRegion(s regionDesc) {
                Tid:      s.G,
                ID:       uint64(regionID),
                Scope:    scopeID,
-               Cname:    colorDeepMagenta,
+               Cname:    pickTaskColor(s.TaskID),
                Arg:      RegionArg{TaskID: s.TaskID},
        }
        if s.End != nil {
@@ -1193,36 +1193,67 @@ func viewerDataTraceConsumer(w io.Writer, start, end int64) traceConsumer {
 // https://github.com/catapult-project/catapult/blob/master/tracing/tracing/base/color_scheme.html#L50
 // The chrome trace viewer allows only those as cname values.
 const (
-       colorLightMauve      string = "thread_state_uninterruptible" // 182, 125, 143
-       colorOrange                 = "thread_state_iowait"          // 255, 140, 0
-       colorSeafoamGreen           = "thread_state_running"         // 126, 200, 148
-       colorVistaBlue              = "thread_state_runnable"        // 133, 160, 210
-       colorTan                    = "thread_state_unknown"         // 199, 155, 125
-       colorIrisBlue               = "background_memory_dump"       // 0, 180, 180
-       colorMidnightBlue           = "light_memory_dump"            // 0, 0, 180
-       colorDeepMagenta            = "detailed_memory_dump"         // 180, 0, 180
-       colorBlue                   = "vsync_highlight_color"        // 0, 0, 255
-       colorGrey                   = "generic_work"                 // 125, 125, 125
-       colorGreen                  = "good"                         // 0, 125, 0
-       colorDarkGoldenrod          = "bad"                          // 180, 125, 0
-       colorPeach                  = "terrible"                     // 180, 0, 0
-       colorBlack                  = "black"                        // 0, 0, 0
-       colorLightGrey              = "grey"                         // 221, 221, 221
-       colorWhite                  = "white"                        // 255, 255, 255
-       colorYellow                 = "yellow"                       // 255, 255, 0
-       colorOlive                  = "olive"                        // 100, 100, 0
-       colorCornflowerBlue         = "rail_response"                // 67, 135, 253
-       colorSunsetOrange           = "rail_animation"               // 244, 74, 63
-       colorTangerine              = "rail_idle"                    // 238, 142, 0
-       colorShamrockGreen          = "rail_load"                    // 13, 168, 97
-       colorGreenishYellow         = "startup"                      // 230, 230, 0
-       colorDarkGrey               = "heap_dump_stack_frame"        // 128, 128, 128
-       colorTawny                  = "heap_dump_child_node_arrow"   // 204, 102, 0
-       colorLemon                  = "cq_build_running"             // 255, 255, 119
-       colorLime                   = "cq_build_passed"              // 153, 238, 102
-       colorPink                   = "cq_build_failed"              // 238, 136, 136
-       colorSilver                 = "cq_build_abandoned"           // 187, 187, 187
-       colorManzGreen              = "cq_build_attempt_running"     // 222, 222, 75
-       colorKellyGreen             = "cq_build_attempt_passed"      // 108, 218, 35
-       colorFuzzyWuzzyBrown        = "cq_build_attempt_failed"      // 187, 187, 187
+       colorLightMauve     string = "thread_state_uninterruptible" // 182, 125, 143
+       colorOrange                = "thread_state_iowait"          // 255, 140, 0
+       colorSeafoamGreen          = "thread_state_running"         // 126, 200, 148
+       colorVistaBlue             = "thread_state_runnable"        // 133, 160, 210
+       colorTan                   = "thread_state_unknown"         // 199, 155, 125
+       colorIrisBlue              = "background_memory_dump"       // 0, 180, 180
+       colorMidnightBlue          = "light_memory_dump"            // 0, 0, 180
+       colorDeepMagenta           = "detailed_memory_dump"         // 180, 0, 180
+       colorBlue                  = "vsync_highlight_color"        // 0, 0, 255
+       colorGrey                  = "generic_work"                 // 125, 125, 125
+       colorGreen                 = "good"                         // 0, 125, 0
+       colorDarkGoldenrod         = "bad"                          // 180, 125, 0
+       colorPeach                 = "terrible"                     // 180, 0, 0
+       colorBlack                 = "black"                        // 0, 0, 0
+       colorLightGrey             = "grey"                         // 221, 221, 221
+       colorWhite                 = "white"                        // 255, 255, 255
+       colorYellow                = "yellow"                       // 255, 255, 0
+       colorOlive                 = "olive"                        // 100, 100, 0
+       colorCornflowerBlue        = "rail_response"                // 67, 135, 253
+       colorSunsetOrange          = "rail_animation"               // 244, 74, 63
+       colorTangerine             = "rail_idle"                    // 238, 142, 0
+       colorShamrockGreen         = "rail_load"                    // 13, 168, 97
+       colorGreenishYellow        = "startup"                      // 230, 230, 0
+       colorDarkGrey              = "heap_dump_stack_frame"        // 128, 128, 128
+       colorTawny                 = "heap_dump_child_node_arrow"   // 204, 102, 0
+       colorLemon                 = "cq_build_running"             // 255, 255, 119
+       colorLime                  = "cq_build_passed"              // 153, 238, 102
+       colorPink                  = "cq_build_failed"              // 238, 136, 136
+       colorSilver                = "cq_build_abandoned"           // 187, 187, 187
+       colorManzGreen             = "cq_build_attempt_runnig"      // 222, 222, 75
+       colorKellyGreen            = "cq_build_attempt_passed"      // 108, 218, 35
+       colorAnotherGrey           = "cq_build_attempt_failed"      // 187, 187, 187
 )
+
+var colorForTask = []string{
+       colorLightMauve,
+       colorOrange,
+       colorSeafoamGreen,
+       colorVistaBlue,
+       colorTan,
+       colorMidnightBlue,
+       colorIrisBlue,
+       colorDeepMagenta,
+       colorGreen,
+       colorDarkGoldenrod,
+       colorPeach,
+       colorOlive,
+       colorCornflowerBlue,
+       colorSunsetOrange,
+       colorTangerine,
+       colorShamrockGreen,
+       colorTawny,
+       colorLemon,
+       colorLime,
+       colorPink,
+       colorSilver,
+       colorManzGreen,
+       colorKellyGreen,
+}
+
+func pickTaskColor(id uint64) string {
+       idx := id % uint64(len(colorForTask))
+       return colorForTask[idx]
+}