liveBook · Manning

Trajectory

As explained in 100 Go Mistakes and How to Avoid Them

An execution tracer is a diagnostic tool that records runtime events such as scheduling, synchronization, and processor activity over time.

An execution tracer records Go runtime events and makes them available for visualization. Use it to investigate performance and understand what happens while an application runs. section 12.8.2

A trace can help diagnose:

Spotting poor parallelization

Tracing a parallel merge-sort benchmark reveals many short goroutine executions and gaps spent orchestrating goroutines rather than running application code. Comparing it with a faster implementation shows longer executions and fewer gaps. section 12.8.2

$ go test -bench=. -v -trace=trace.out

Run a benchmark with tracing enabled to create a trace file for inspection. section 12.8.2

Figure 12.40 Too many small bars mean poorly parallelized execution.

Many short bars in the timeline indicate poorly parallelized execution. section 12.8.2

How 100 Go Mistakes and How to Avoid Them covers it

How deep it goes
Explains event capture and timeline interpretation, including goroutine activity, CPU gaps, and garbage collection.
Examples
Compares traces from two parallel merge-sort implementations to expose goroutine overhead and differences in execution.
What you can do after
Diagnose poor parallelization by capturing and inspecting a Go execution trace.
How it connects
Connects profiling with goroutines, garbage collection, and concurrency.

Also explained in

Compare how 19 books explain trajectory →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 Go Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.