Checking how many agents are working

How this works
Contatti
← Blog
A wide steel pipe narrowing to a thin brass tube in the middle on a dark bench with water droplets of teal light, lit with a warm amber highlight at the narrow point, the AMARBARO mark and wordmark centered over it.
✎post del blog

The bottleneck is not always where you think

The short version

The slow part of a system is the narrowest link in its chain, and reading the link before timing anything that crosses it is the cheapest way to find it.

Part 14 in Measuring things honestly. Earlier parts include waiting on memory or on math.

What this is about

A chain is only as fast as its slowest link. If you make a fast part faster, the chain does not speed up, because the slow link still limits it. That slowest link is called the bottleneck.

The trouble is that the bottleneck is often not where we expect. This article tells how we found one in a place we were not looking, with a trace, a log line and a table.

Why it matters

People spend weeks tuning a part that is not the limit. A bottleneck hunt that starts from the right place saves all of that.

It also teaches a habit. Before you time anything, check that the machine you are timing is the machine you think it is.

How it works

Step 1: Record what the system does

We trace our language-model engine while it generates 32 tokens, using a profiler called rocprofv3. A trace records every kernel and every memory copy, with times. We grouped every gap between kernels by what came before it.

Step 2: Read the idle time

The window was 1091 ms long and the GPU was idle for 656 ms of it. The kernels themselves were busy 14 ms per token. The GPU sat idle for 20.5 ms of every token, which is 60 percent of the wall time.

Where did the idle go?

What the gap came after Time per token What it is
Choosing which model part to use (long gaps only) 11.31 ms Copying in a model part that was not on the card
End of token 3.85 ms The main processor reads results and starts the next token
The short pause between any two kernels 2.43 ms 11,647 gaps of about 6.7 microseconds each

The biggest slice was copying. Our model keeps only some of its expert parts on the card, and when one is missing it is copied in. Each miss issued three copies of 460,800 bytes. Each took about 150 microseconds.

Step 3: Do the arithmetic on the copy

460,800 bytes in about 150 microseconds is 3.1 GB per second. On a healthy boot, the same card had reached 28.5 GB per second. At that speed, the same copy takes about 16 microseconds. The copy code was not slow. The wire was.

The host, the main processor that hands work to the card, was not the limit either. Its share was about 3.3 ms per token. We had still spent an hour on the host side before looking at the link.

Step 4: Probe the link on its own

Plain copy tests of 460,800 bytes, 4 MB and 64 MB all ran at 3.1 to 3.6 GB per second, with the GPU busy or idle. The kernel log said why:

limited by 2.5 GT/s PCIe x16 link at 0000:00:01.1 (capable of 16.0 GT/s PCIe x16 link)

The slot on the motherboard had agreed on a speed of 2.5 GT/s, the oldest and slowest setting, when it can do 16. A trap here: the card's own end of the link always reports 16, because that is the link inside the card. Read the other end, at the root port.

Step 5: Look across boots

Boot Root port Measured host copies
2026-09-09 full speed 28.5 GB/s
2026-09-11 2.5 GT/s 3.60 GB/s
2026-10-14 2.5 GT/s 3.60 GB/s
2026-10-19 2.5 GT/s 3.1 to 3.4 GB/s

The software settings were clean, and there were zero correctable errors on both ports. The link was not erroring. It negotiated low when the machine started. Why it does so on some boots is not established, and our fault note says unverified.

What it cost

Every timing on that boot that moved data between the host and the card is void. That includes several comparisons we had run. One result survives: a change that cut GPU launches per token from 1244 to 992 had a same-boot ratio of 0.9536, with the new version faster on 20 of 20 prompts. Both versions ran on the same slow link, so the ratio is fair. The milliseconds are not comparable with a healthy boot, and we do not quote them.

The fix is not in yet. A BIOS change gave one boot at full speed, and one good boot is not enough. A reboot usually clears the fault and it comes back.

Our own tools had a blind spot. The fault had been logged since 2026-09-11, but our search for it did not find it, because the note used different words. And our timing scripts never read the link first. A script now records the link speed in every comparison receipt, and flags the result if it is not 16 GT/s.

The rule

Read the link before you time anything that crosses it.

What counts and what does not

Counts:

  • The root port's current link speed, read in the same boot as the timing.
  • A receipt that carries the link speed beside the number.

Does not count:

  • The card's own end of the link, which says 16 GT/s whatever happens.
  • A time from a boot with the link down, compared with a healthy one.

Glossary

  • Bottleneck: the slowest link in a chain, which limits the whole.
  • PCIe: the connection between a graphics card and the rest of the computer.
  • GT/s: gigatransfers per second, a measure of link speed.
  • Root port: the motherboard's end of the link.
  • Trace: a timeline of everything a program and a device did.
  • Kernel: a small program running on the GPU.
  • Token: a small piece of text.

Try it

Think of a chain you use daily, such as a download that crawls. List each link: disk, network, browser. Test each link alone. Which is the narrowest?

For GPU code, the wavewait page shows how a trace turns into a per-instruction table, so you can see waits and not only busy time. Our full story is in The Bottleneck Was the PCIe Link.

What to remember

The bottleneck is the narrowest link. Check the links first, before you tune the parts.

Commenti

Ancora nessun commento.

Accedi per commentare.