Overview of Performance Tracing Tools and Architecture

September 27, 2018 

Overview of Performance Tracing Tools and Architecture

What is Performance Tracing?

Golang involves runtime execution tracer to capture a wide range of run-time events. Scheduling, syscall, garbage collections, heap size, and events collected by the runtime available for visualization by the Go tool trace. Execution tracer detects latency and utilization problems. CPU utilization and networking or syscalls are a cause of preemption for the goroutines.

Performance Monitoring performed in two ways -

  • Using trace parameter
  • Open tracing

Why Performance Tracing Matters?

  • Check how all cores of the processor are used to execute a function.
  • Identifies how all cores are being used either in case of go concurrent programming or go sequential way of programming.

How Performance Tracing Works?

Components available on visualization dashboard, trace code through this dashboard and understand the result. Result accessible from the main dashboard.

The need for these components explained below and for what purpose each component used is -

View trace

  • It is the most powerful and interactive visualization tool which represents the execution time for an entire program.
  • It represents information like what processes are running at each virtual processor, what methods are in a blocked state and waiting to execute.
  • This visualization only works at chrome browser.

Go routine analysis

  • It represents information like what are new goroutines created during execution of one goroutine.
  • This analysis helps us to represent information like how much time routine blocked while trying to acquire new resources and how much it was blocking when it was waiting to acquire a lock on a mutex(resources).
  • Network/Sync/Syscall blocking profile. It reveals for how long goroutines blocked on each of resources. It acts as a memory/CPU profiling.

Scheduler latency profiler

  • Scheduling is a way to allocate resources (e.g., CPU)to a process,which helps in the execution of processes.
  • It process in such a way that a higher priority process is selected first.

Different type of schedulers helps in an execution of a process by priority. There are three types of scheduler like short term, long term, medium term scheduler which selects a process for execution. It is all about scheduling that how CPU allocated to processes. Scheduler latency profiler helps to check time spent by the scheduler for scheduling of processes.


How to Adopt Performance Tracing?

Firstly, generate a trace. out file of code. To create a trace file code, the following command can be followed -


go test -run=. -bench=. -cpuprofile=cpu.pprof -benchmem -memprofile=mem.out -trace.trace.out

Wherever a trace.out is generated, then visualization on this file can be done by this command -

go tool trace trace.out
  • View trace
  • Go routine analysis
  • Network blocking profile
  • Synchronization blocking profile
  • Syscall blocking profile
  • Scheduler latency profile

Now visualization for each component present at a web browser(chrome)is possible by just clicking on it.


Visualization for View Trace

Click on a Go routine analysis.

After clicking on a Go routine analysis following components will be visible .These components are listed below -

  • testing.(*B).launch N=1
  • runtime.gcBgMarkWorker N=4
  • runtime.main N=1
  • runtime.bgsweep N=1
  • Projects/Doc_demo/main.init.0.func1 N=1
  • testing.(*B).run1.func1 N=1
  • runtime.timerproc N=1
  • runtime/trace.Start.func1 N=1
  • testing.runTests.func1.1 N=1
  • N=2
  • testing.(*B).launch N=1

Go routine analysis

Click on a Go routine number. In the same way visualization for other components is possible.

  • Visualization for Network blocking profile
  • Visualization for Synchronization Blocking Profile
  • Visualization for Syscall blocking profile
  • Visualization for Scheduler latency profile

Benefits of Performance Tracing

  • Understand goroutines execution.
  • Understand core runtime events like GC runs.
  • Identify poorly parallelized execution.

Performance Tracing Tools

For tracing, there is no specific tool. Usually, Testing package code written in such a way that helps in a tracing. Executing a tracing regrading command will directly open a dashboard at the web. Hence, not any special tool is required.