Performance, under the hood · check

Know What the profiler is really showing you already?

One question for each of the 6 puzzles in this module. A right answer marks that puzzle as passed, so you can jump ahead. A wrong one tells you which puzzle to start with. Nothing is sent anywhere: it's saved in this browser.

Puzzle 0: A photo or a diary

A function runs for 50 µs, once, between two snapshots. Which tool can miss it entirely?

Not quite. A trace section records whatever span you wrap; the risk of missing it is sampling's. Learn it in puzzle 0 →

Not quite. Instrumentation records every method's start and end, however short. Learn it in puzzle 0 →

Right. A snapshot misses what started and ended between two snapshots.

Puzzle 1: Reading the flames

In a flame chart, format() is drawn left of parseJson(). What does that tell you?

Right. Width is time; position isn't.

Not quite. A caller and its callees are stacked, not side by side. Learn it in puzzle 1 →

Not quite. That's a call chart. In a flame chart the order is by width, not by when. Learn it in puzzle 1 →

Puzzle 2: Slow isn't always busy

In another trace, a 120 ms main-thread span is 110 ms Sleeping. What will making its code faster save?

Not quite. Only Running time is code running; Sleeping is waiting for something else. Learn it in puzzle 2 →

Right. Faster code shortens only Running.

Not quite. Sleeping ends when what it waits for arrives, not when the CPU is faster. Learn it in puzzle 2 →

Puzzle 3: The late frame

A frame's main thread finished well before the deadline, but FrameTimeline marks it late. What can explain it?

Not quite. The expected window is the app's budget; the GPU work came on top. Learn it in puzzle 3 →

Not quite. The Actual Timeline ends at the later of posting and the GPU finishing. Learn it in puzzle 3 →

Right. Actual ends at max(GPU, post time).

Puzzle 4: What the collector costs

Why is creating an object in ART cheap?

Not quite. It doesn't; allocation is fast because the space is the thread's own and contiguous. Learn it in puzzle 4 →

Right. Own space, one pointer bump.

Not quite. Kotlin objects live on the heap; the speed comes from the TLAB. Learn it in puzzle 4 →

Puzzle 5: What a heap dump proves

An old Activity has a shallow size of 400 bytes and a retained size of 12 MB. What does freeing it save?

Right. Retained size is what you really get back.

Not quite. A destroyed Activity is collected like any object, once unreachable. Learn it in puzzle 5 →

Not quite. That's shallow size; retained size counts everything that goes with it. Learn it in puzzle 5 →

Back to the overview →