Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ project follows [Semantic Versioning](https://semver.org/).

## [Unreleased]

### Fixed

- The throughput sparkline of short runs no longer stays flat at "peak 0"
next to a real average. It is now derived from the bytes written over time
instead of point-in-time rate snapshots that missed most of a short write,
and finished runs show their peak instead of an always-zero current rate.

## [1.2.0] — 2026-10-14

### Added
Expand Down
7 changes: 4 additions & 3 deletions web/src/components/Sparkline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { computed } from 'vue'

// A dependency-free inline-SVG line chart for a throughput series.
const props = withDefaults(
defineProps<{ values: number[]; width?: number; height?: number; unit?: string }>(),
{ width: 220, height: 40, unit: 'MB/s' },
defineProps<{ values: number[]; width?: number; height?: number; unit?: string; live?: boolean }>(),
{ width: 220, height: 40, unit: 'MB/s', live: false },
)

const max = computed(() => Math.max(1, ...props.values))
Expand Down Expand Up @@ -39,7 +39,8 @@ const latest = computed(() => props.values[props.values.length - 1] ?? 0)
/>
</svg>
<span class="font-mono text-xs whitespace-nowrap text-slate-500">
{{ latest.toFixed(0) }} {{ unit }} · peak {{ peak.toFixed(0) }}
<template v-if="live">{{ latest.toFixed(0) }} {{ unit }} · </template>peak {{ peak.toFixed(0) }}
<template v-if="!live">{{ unit }}</template>
</span>
</div>
</template>
31 changes: 31 additions & 0 deletions web/src/throughput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { RunSample } from './api'

const MiB = 1024 * 1024

// Minimum span a rate is averaged over. Agents report every 5s and the
// controller samples every 5s, so a single interval aliases (0, 2x, 0, ...);
// averaging over two intervals smooths that out.
const WINDOW_SEC = 10

// throughputSeries turns a run's samples into a MB/s series (MiB-based, like
// the run summary's avgMBps) for the sparkline.
//
// The stored mbps is a snapshot of the agents' instantaneous rate, summed over
// VMs still working. On short runs it is mostly 0: a VM writes its few GiB
// between two snapshots and reports done before the next one. The cumulative
// bytesWritten in every sample doesn't miss anything, so the rate is derived
// from it and the snapshot is used only when it is higher (a real
// instantaneous burst).
export function throughputSeries(samples: RunSample[]): number[] {
const t = samples.map((s) => Date.parse(s.ts) / 1000)
let lo = 0
return samples.map((s, i) => {
while (lo < i - 1 && t[i] - t[lo + 1] >= WINDOW_SEC) lo++
let derived = 0
const dt = t[i] - t[lo]
if (i > 0 && dt > 0) {
derived = Math.max(0, s.bytesWritten - samples[lo].bytesWritten) / MiB / dt
}
return Math.max(derived, s.mbps)
})
}
4 changes: 3 additions & 1 deletion web/src/views/DeploymentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import SpecForm from '../components/SpecForm.vue'
import SearchableSelect from '../components/SearchableSelect.vue'
import MultiSelect from '../components/MultiSelect.vue'
import Sparkline from '../components/Sparkline.vue'
import { throughputSeries } from '../throughput'

const deployments = ref<Deployment[]>([])
const profiles = ref<Profile[]>([])
Expand Down Expand Up @@ -156,7 +157,7 @@ async function loadSamples(deploymentId: string, runs: Run[]) {
if (run.type !== 'initial-fill' && run.type !== 'incremental' && run.type !== 'verify') continue
try {
const s = await api.listRunSamples(deploymentId, run.id)
runSamples.value = { ...runSamples.value, [run.id]: s.map((p) => p.mbps) }
runSamples.value = { ...runSamples.value, [run.id]: throughputSeries(s) }
} catch {
/* ignore */
}
Expand Down Expand Up @@ -1662,6 +1663,7 @@ const labelClass = 'block text-xs font-medium text-slate-500 mb-1'
<Sparkline
v-if="runSamples[run.id] && runSamples[run.id].length > 1"
:values="runSamples[run.id]"
:live="run.status === 'running'"
/>
</td>
<td
Expand Down
Loading