Tachyon workshops

Back to Workshops

Guided JupyterLab workshops for Tachyon, the sampling profiler in Python 3.15: what a sampling profiler is and how to read one, then profiling real applications with it.

Launch the workshops

Each option opens the whole collection in a new window, where JupyterLab shows the workshops in the order to take them.

  • Binder is a free public service needing no account. Sessions are temporary and can take a minute or two to start.
  • Codespaces needs a GitHub account and uses your Codespaces allowance. A codespace is kept until you delete it.

Profiling with Tachyon

Guided JupyterLab workshops on Tachyon, the sampling profiler in Python 3.15: what a sample is and why sampling costs nothing, reading the table, the flame graph and the heatmap, choosing wall, CPU, GIL or exception time, threads, async code, native code and the garbage collector, bytecode, comparing two profiles, and watching a program live.

14 workshops About 3h 45m python tachyon profiling
1 Your first profile 15m

Run Tachyon, the sampling profiler in Python 3.15, on a small report generator and read the table it prints. Learn what a sample is, why time is samples multiplied by an interval, why the same function can fill two rows, and which of the report's functions is eating the time.

2 Sampling or tracing? 15m

Run the same report under cProfile, now also called profiling.tracing, and under Tachyon. Exact call counts against estimates, the overhead each imposes and why it depends on how many calls a program makes, and which profiler to reach for when.

cprofile
3 Reading a process from the outside 15m

How Tachyon sees the call stack of another process without running any code in it, why that needs permission on most systems, why the profiler and the program must be the same Python, and what the error rate and the blocking option mean.

4 Reading a flame graph 15m

Turn a Tachyon profile into the interactive flame graph the profiler writes and read it beside the instructions, on a page renderer whose hot function has several callers. What width and depth mean, zooming, search, the sidebar, and the collapsed stacks text the picture is drawn from.

flamegraph
5 Down to the line 15m

Paint a Tachyon profile onto the source code with the heatmap, on a report whose slow function is twenty lines long and slow on one of them. The index of files, the page per file, self and total time, the hot-only filter, and the same file before and after the fix.

heatmap
6 Record now, look later 15m

Record a Tachyon profile once in the compact binary format and turn it into a table, a flame graph and a heatmap afterwards with replay. Then the formats for other tools, the gecko file the Firefox Profiler reads, JSONL for your own scripts and the pstats file, and what each output is for.

formats
7 Waiting or working? 15m

Find out whether a slow program is computing or waiting, with Tachyon's wall-clock and CPU modes, on a feed reader that fetches from a slow server and then merges what it fetched. What each mode keeps, why the two tables disagree, and what the disagreement says about the fix.

modes
8 Who holds the GIL? 20m

Profile a program with several threads using Tachyon. Why the default profile shows only a thread that is waiting, what -a adds, the flame graph's view of each thread, and GIL mode, on four threads of Python that take as long as one and four threads of hashing that do not.

threads gil
9 The price of an exception 15m

Measure the time a program spends under an exception with Tachyon's exception mode, on a date parser that tries one format after another. What the mode counts, why raising is cheap and the handler is not, and the profile before and after the fix.

exceptions
10 Following the awaits 15m

Profile a program written with asyncio, a crawler that fetches twenty feeds at once, first as the event loop's stack and then with Tachyon's async-aware profiling, which follows the tasks. What each view shows, what the tasks that are not running are waiting for, and which options cannot be combined with it.

asyncio
11 Native code and the collector 20m

See two things the Python stack cannot show, with the markers Tachyon adds to it. The native marker, on a search index whose sort calls back into Python from C, and the collector's marker, on a graph of cross-references that gives the garbage collector work to do. What each marks, what it leaves out, and how far to trust the counts.

native gc
12 Down to the bytecode 15m

Record the bytecode instruction the interpreter was executing at each sample, with Tachyon's opcodes option, on a program that scores articles for readers. What the specialising interpreter does to a hot loop, how to read the instructions under a line of the heatmap, and what changes when one function is given objects of eight classes.

bytecode
13 Did the fix work? 20m

Compare two profiles of one program with Tachyon's differential flame graph, on a report generator that is fixed and then changed again. How to record a baseline, what the colours mean and what they are measured against, what noise looks like, and why each change is compared with the profile made just before it.

flamegraph
14 Watching it live 15m

Watch where a program spends its time while it runs, with Tachyon's live mode, on a report that is rebuilt over and over. How to read the display and drive it from the keyboard, and then how many samples are enough, with the rate and duration options and the statistics that say whether the profiler kept up.

live

Tachyon on real applications

Guided JupyterLab workshops that point Tachyon at the programs people run: a Flask application under load, a slow endpoint found and fixed, an async service that stalls, worker processes, a test suite, attaching to a process that is already running, and a profile carried from production to your desk.

7 workshops About 2h 10m python tachyon profiling web
1 A Flask application under load 20m

Profile a web application with Tachyon, a small Flask site started under the profiler for a fixed time and sent requests from a second terminal. What is different about profiling a server, what the flame graph of one looks like, thread by thread, and what wall-clock and CPU time each say about it.

flask web
2 The slow endpoint 20m

Find out why one page of a web application is slow, fix it and prove the fix, with Tachyon. A baseline recorded under load, the flame graph to find the view, the heatmap to find the line, a query in a loop replaced by one query, and a second recording compared with the first.

flask web
3 An async service that stalls 25m

Find what is holding up an asyncio web service with Tachyon, a Starlette application under uvicorn whose searches slow down when articles are being read. The event loop's thread in a flame graph, the tasks in an async-aware table, a fix with a thread that does not work and why, and one with a process pool that does.

asyncio web
4 Workers and subprocesses 15m

Profile a program that does its work in other processes, with Tachyon's --subprocesses option. A job runner on a pool of four processes, whose own profile is all waiting, and a web site under gunicorn with three workers. What the profiler follows, the file it writes for each process, how to tell the files apart, and why a machine may refuse the children.

multiprocessing gunicorn
5 Profiling a test suite 15m

Find out where a slow test suite spends its time, with Tachyon around pytest. A recording of the whole run, the flame graph with the tests and the fixtures in it, the heatmap of conftest.py, and three fixes to three common habits, a fixture rebuilt for every test, a sleep where a join would do, and a file parsed once for each case.

pytest testing
6 Attaching to a running process 15m

Profile a web application that is already running, without restarting it, with Tachyon's dump and attach commands. A snapshot of every thread's stack, and a flame graph of fifteen seconds of a server that never knew. Who the kernel lets read a process, how to find out what your machine allows, and what to do where it is refused.

attach flask
7 A profile from production 20m

Carry a profile from the machine that made it to a notebook and a chart, with Tachyon's binary recordings and replay. Two captures of a web application under load, a week and a fix apart, replayed at the desk as a flame graph and as JSON lines, then loaded in a notebook, totalled by function and drawn side by side.

notebook flask