Checkpoint Timeline Viz
An interactive visualisation of the checkpoint-interval tradeoff in long training runs. Three sliders (interval, size, write speed) feed a derived I/O-overhead readout; clicking Simulate failure runs the timeline forward, pausing at each checkpoint, then crashes at a random step and reveals how much work was lost between the last save and the failure.
Tighter intervals cap the maximum steps_lost at the cost of more I/O overhead. Larger checkpoints lengthen each write and push overhead up faster. Faster write speed (NVMe vs SATA) shortens each pause; the slider lets the visitor feel the difference.
Checkpoints every 500 steps balance I/O cost (100.0% overhead) against recovery risk. Click "Simulate failure" to see where a crash would land.
Installation
npx shadcn@latest add https://craftbits.dev/r/checkpoint-timeline-viz.jsonUsage
import { CheckpointTimelineViz } from "@craft-bits/viz/checkpoint-timeline-viz";
<CheckpointTimelineViz />Start with a wider interval so the visitor sees a worst-case-style failure:
<CheckpointTimelineViz defaultInterval={1500} />Subscribe to the failure event for an external chart:
<CheckpointTimelineViz
onFailure={({ stepsLost, failureStep }) => {
/* lift stepsLost into a chart */
}}
/>Understanding the component
- The timeline. A horizontal track spans
0tototalSteps(default10,000). Save icons mark every checkpoint, staggered in on entry so the eye reads the cadence at a glance. - Sliders. Three native
input[type=range]controls — interval, checkpoint size, and write speed. Each change clears any pending failure and resets the timeline. - Simulate failure. Picks a random step inside
[200, totalSteps − 200], then springs the progress bar forward at a fixed visual speed. At each checkpoint the bar pauses for a short window to show the disk write, recolouring to the warning palette. - Crash. The lightning marker drops onto the failure step. A red band fills the gap between the last checkpoint and the crash; a recovery arrow points back to "resume here". The stats grid fades in below.
- I/O overhead colour. Green when
≤ 5%, amber when≤ 30%, red beyond — the same threshold an engineer would use to flag "checkpointing is eating my throughput". - Reduced motion. Under
prefers-reduced-motion: reduce, the progress run collapses to a single snap and every entrance / shake / pulse disables.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
defaultInterval | number | 500 | Initial checkpoint interval in steps. Clamped to [50, 2000]. |
defaultSizeGB | number | 15 | Initial checkpoint size in GB. Clamped to [1, 100]. |
defaultWriteSpeed | number | 3 | Initial write speed in GB/s. Clamped to [0.5, 5]. |
totalSteps | number | 10000 | Total training steps modelled by the timeline. |
stepTimeSeconds | number | 0.01 | Wall-clock seconds per training step. Drives the "time lost" stat. |
transition | Transition | SPRINGS.snap | Override marker entrance / progress animation transition. |
onFailure | (info) => void | — | Fires once after the simulated failure resolves. |
className | string | — | Merged onto the root via cn(). |
Accessibility
- The timeline is
role="img"with anaria-labelsummarising its purpose; markers and tick labels arearia-hiddenso the live region drives the story for screen readers. - A polite live region announces the current narration — overhead percentage, suggested next move, recovery cost after a crash — without spamming on every slider tick.
- Sliders are native
input[type=range]so they inherit the platform-default keyboard model (arrow keys, Home/End) and receive visible focus rings. - The
Simulate failurebutton disables while the simulation is running so repeat-clicks can't queue a second run. - Colour is never the only signal — the narration prose and the stats grid both encode the recovery cost as text.
- Motion respects
prefers-reduced-motion: reduce— the progress run collapses to a single snap and every entrance animation disables.
Credits
- Extracted from:
craftingattention(app/src/lessons/primitives/systems/CheckpointTimelineViz.tsx). The source was a lesson component that bundled aWidgetchrome, aModeStripflip between Explore / Predict / Challenge, and theChallengeBtn/FeedbackBadge/ScoreDotsquiz UI. The viz extract keeps only the interactive timeline + simulate-failure path — the predict and challenge multiple-choice rounds were curriculum-specific and live in the lesson source. Per-track palette tokens are remapped tovar(--cb-*)semantic tokens so consumer themes repaint freely, and inlineSPRINGS.snappy/SPRINGS.gentleare re-keyed to the canonicalSPRINGS.snap/SPRINGS.smoothfrom@craft-bits/core/motion.