Skip to content

Why Is My First Scenario Slow

aryehcitron@gmail.com edited this page Nov 2, 2026 · 4 revisions

Why is my first scenario slow?

Often because it went first. The first request down each path pays the app's one-time warm-up: the JIT, a GraphQL schema build, a first database connection. On BreakfastProvider's CI run of 2026-10-05 the run's first POST /graphql took 55 to 115 times what later ones did, and whichever scenario made it carried the cost.

What Kronikol marks (4.8.0)

For each kind of call a test makes (its service, its method and its path with ids, numbers and timestamps folded; a statement's templated head for a database), the run's first call is a first-call warm-up when it took at least 10 times and 50 ms more than the median of the calls of its kind that started after it ended. A call that started while it ran and waited for it is marked too. A first call that failed with a 5xx is compared only with later calls that failed so. The app's own calls, a message a broker delivered or the test took from it, and the background are not judged, and a kind of call made once is not judged either. A publish the test makes is judged (since 5.28.1). Since 5.17.0 a kind of call is read as history reads it: a GraphQL request by its operation, so each operation on one endpoint is judged against its own calls, where every operation shared the endpoint's median and a slow query hid behind fast ones; a statement past a prologue of SET statements, so EF Core's SQL Server batches are judged by what they insert or update.

  • The data files carry warmUp on each marked call and warmUpSeconds on its scenario (Generated Reports); durationSeconds is unchanged.
  • kronikol query summary ranks Slowest by each scenario's own time and says where the warm-up went; flow and interactions mark the calls; scenarios --slower-than and the run diff's Slower read the time left (Querying Reports).
  • The HTML report (4.9.0) keeps a marked scenario's wall time as its duration badge and adds the warm-up as muted text, 2.0s · 1.5s warm-up, with the calls named when you hover over it; the Scenario Timeline shades the warm-up's share of the scenario's bar, and the P50 to P99 filter ranks each scenario by its own time (Generated Reports).
  • HistoryShapeTemplates (Report Configuration) fold your own ids in the kinds of call too: without them an id the built-in templates do not know splits a kind, which only marks less.

On BreakfastProvider's CI run the rule marked 10 calls in 7 of 212 scenarios (xUnit) and 18 in 17 of 214 (ReqNRoll).

What it cannot see

  • A path called once. With nothing to compare it with, a single call's warm-up cannot be told from its work.
  • A first call whose later calls all overlapped it. No call ran warm after it.
  • An event-driven wait. A scenario that polls for an event waits on the app's consumer, whose first message pays the warm-up; the test's own calls are not slow.
  • A publish no table can read. At Raw a broker's label is the HTTP verb, or holds Kafka's offset, and MessageTracker writes a scheme of its own, so those are not judged.
  • A second host. A test that builds its own host pays part of the warm-up again. Only the run's first call of each kind is judged, and nothing records which host served a call.
  • Parallel lanes. Only a call that overlaps the first is judged a waiter, so a later call that is still slow is not marked.
  • Several processes in one ingest (Ingesting External Captures): each kind's first call across all the files is judged, and another process's own first call is not.

How to avoid it

Measured on BreakfastProvider's xUnit lane: as it is, the run's first POST /graphql took 440 and 737 ms against later medians of 7.0 and 5.4 ms. With HotChocolate's InitializeOnStartup() it took 108 ms, and with InitializeOnStartup(warmup: ...) running a real query 25 ms, and that call was not marked.

  • Send one request down each expensive path before the first scenario, from an assembly or collection fixture, through a client Kronikol does not track (or a tracked one outside any test, whose calls land in no scenario).
  • For HotChocolate, InitializeOnStartup(warmup: (executor, ct) => ...) with a real query: the schema alone leaves a first execution of about 100 ms. It runs as a hosted background service, so a suite whose first scenario is a GraphQL one can still wait on it.
  • The trade: a warm-up hides the first-request cost production users pay after a deploy. If that matters, test it on purpose, in a scenario of its own, and let the mark show it.

Home · 🔍 Search this wiki Full-text search across every page. The “Pages” list above matches page and heading names, not page content.


Demo


Getting Started

Common Tasks

Integration Guides

Uninstrumentable / polyglot backends

Extensions

Configuration

Features

Reference

Clone this wiki locally