XenonStack Recommends

TestOps

Overview of Performance Tracing Tools and Architecture

Navdeep Singh Gill | 21 April 2022

 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.

The primary goal of performance tuning is to find bad parts /bottlenecks of code and to improve a bad parts/bottlenecks of codes. Click to explore about, Performance Tuning Tools and Architecture

Performance Monitoring performed in two ways -

  • Using trace parameter
  • Open tracing

Why Performance Tracing is important?

  • Check how all cores of the processor are used to execute a function.
  • Identifies how all cores are being used either in case of going 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 the 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 the 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 the time spent by the scheduler for scheduling of processes.
A distributed SQL database built on a transactional and strongly-consistent key-value store. Click to explore about, CockroachDB Architecture and Performance

How to adopt Performance Tracing?

Firstly, generate a trace. out the 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

A non-functional type of testing that measures the performance of an application or software under a certain workload based on various factors like responsive rates, CPU and resource utilization, and stability. Click to explore about, Performance Testing Tools and Its Best Practices

What are the benefits of Performance Tracing?

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

Conclusion

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.