staging-tester / ocean-landing-serve / src/ routes/ benchmarks/ +page.svelte

<script lang="ts">
	import ArrowRightIcon from 'phosphor-svelte/lib/ArrowRightIcon';
	import DatabaseIcon from 'phosphor-svelte/lib/DatabaseIcon';
	import HardDrivesIcon from 'phosphor-svelte/lib/HardDrivesIcon';
	import SigmaIcon from 'phosphor-svelte/lib/SigmaIcon';
	import TimerIcon from 'phosphor-svelte/lib/TimerIcon';
	import LeavesOut from '#lib/components/site/benchmarks/LeavesOut.svelte';
	import MethodDiagram from '#lib/components/site/benchmarks/MethodDiagram.svelte';
	import PackSizes from '#lib/components/site/benchmarks/PackSizes.svelte';
	import Footer from '#lib/components/site/Footer.svelte';
	import OperationTimes from '#lib/components/site/home/OperationTimes.svelte';
	import Navbar from '#lib/components/site/Navbar.svelte';
	import { cases, cpuPerGb, formatBytes, formatMs, method } from '#lib/benchmarks.js';

	const count = new Intl.NumberFormat('en-US');
	const times = (a: number, b: number) => `${(b / a).toFixed(1)}x`;

	const steps = [
		{
			icon: DatabaseIcon,
			title: 'One repository',
			detail: `A copy of ${method.repository}, the Linux kernel, with ${count.format(cases[0]?.objects ?? 0)} objects.`
		},
		{
			icon: HardDrivesIcon,
			title: 'One machine',
			detail: `Both servers run on ${method.machine}, so the network plays no part. Stock git is upload-pack ${method.gitVersion} with a pack bitmap, its fastest setup.`
		},
		{
			icon: TimerIcon,
			title: 'Server time only',
			detail: 'The clock measures how long the server takes to send its first pack byte and the whole pack, in process, so HTTP and the network are left out.'
		},
		{
			icon: SigmaIcon,
			title: 'Median of five',
			detail: `Each operation runs ${method.runs} times after one warm-up, and the median is reported.`
		}
	];
</script>

<svelte:head>
	<title>Sailfork benchmarks</title>
	<meta
		name="description"
		content="Time to first byte and time to send the whole pack for a Linux clone, Sailfork against stock git upload-pack."
	/>
</svelte:head>

<Navbar />

<main>
	<header class="pt-10 pb-16 sm:pt-16">
		<div class="mx-auto grid max-w-7xl gap-8 px-4 sm:px-6 lg:grid-cols-12 lg:items-end lg:px-8">
			<h1 class="type-display lg:col-span-8">The Linux kernel, timed on both sides.</h1>
			<p class="type-lead max-w-[40ch] text-muted-foreground lg:col-span-4">
				Sailfork against stock git on the same machine, measuring only what the server does.
			</p>
		</div>
	</header>

	<section aria-labelledby="results-title" class="border-t border-border py-20">
		<div class="mx-auto grid max-w-7xl gap-10 px-4 sm:px-6 lg:grid-cols-12 lg:px-8">
			<h2 id="results-title" class="type-title lg:col-span-4">Results</h2>
			<div class="grid min-w-0 gap-16 lg:col-span-8">
			<OperationTimes />
			<div class="min-w-0">
				<p class="type-heading">Every number</p>
				<div class="mt-4 overflow-x-auto">
					<table class="w-full min-w-[40rem] border-collapse text-left">
						<thead>
							<tr class="type-small border-b border-border text-muted-foreground">
								<th scope="col" class="py-3 pr-4">Operation</th>
								<th scope="col" class="px-4 py-3">Server</th>
								<th scope="col" class="px-4 py-3 text-right">First byte</th>
								<th scope="col" class="px-4 py-3 text-right">Whole pack</th>
								<th scope="col" class="py-3 pl-4 text-right">Pack size</th>
							</tr>
						</thead>
						{#each cases as c (c.id)}
							<tbody class="border-b border-border">
								<tr class="align-top">
									<th scope="rowgroup" rowspan="2" class="py-4 pr-4 text-left">
										<span class="type-heading block">{c.label}</span>
										<span class="type-small mt-0.5 block text-muted-foreground"
											>{count.format(c.objects)} objects</span
										>
									</th>
									<td class="type-body px-4 pt-4 pb-1">Sailfork</td>
									<td class="type-heading px-4 pt-4 pb-1 text-right tabular-nums">{formatMs(c.sailfork.firstByteMs)}</td>
									<td class="type-heading px-4 pt-4 pb-1 text-right tabular-nums">{formatMs(c.sailfork.doneMs)}</td>
									<td class="type-body pt-4 pb-1 pl-4 text-right tabular-nums">{formatBytes(c.sailfork.packBytes)}</td>
								</tr>
								<tr class="text-muted-foreground">
									<td class="type-body px-4 pt-1 pb-4">git {method.gitVersion}</td>
									<td class="type-body px-4 pt-1 pb-4 text-right tabular-nums">{formatMs(c.git.firstByteMs)}</td>
									<td class="type-body px-4 pt-1 pb-4 text-right tabular-nums">{formatMs(c.git.doneMs)}</td>
									<td class="type-body pt-1 pb-4 pl-4 text-right tabular-nums">{formatBytes(c.git.packBytes)}</td>
								</tr>
							</tbody>
						{/each}
					</table>
				</div>
				<p class="type-small mt-4 max-w-[70ch] text-muted-foreground">
					On a full clone Sailfork sends the whole pack {times(cases[0]?.sailfork.doneMs ?? 1, cases[0]?.git.doneMs ?? 1)} faster;
					on a shallow clone, {times(cases[1]?.sailfork.doneMs ?? 1, cases[1]?.git.doneMs ?? 1)}; on a fetch of the last
					100 commits, {times(cases[2]?.sailfork.doneMs ?? 1, cases[2]?.git.doneMs ?? 1)}. Serving a full
					clone also takes {(cpuPerGb.git / cpuPerGb.sailfork).toFixed(2)}x less CPU per GB: {cpuPerGb.sailfork} s against
					{cpuPerGb.git} s.
				</p>
				<p class="type-small mt-3">
					<a href="/#race" class="inline-flex items-center gap-1 text-primary underline underline-offset-4">
						Watch it replayed<ArrowRightIcon class="size-3.5" aria-hidden="true" />
					</a>
				</p>
			</div>
			<PackSizes />
			</div>
		</div>
	</section>

	<section aria-labelledby="method-title" class="border-t border-border py-20">
		<div class="mx-auto grid max-w-7xl gap-10 px-4 sm:px-6 lg:grid-cols-12 lg:px-8">
			<h2 id="method-title" class="type-title lg:col-span-4">How it was measured</h2>
			<div class="grid min-w-0 gap-14 lg:col-span-8">
			<MethodDiagram />
			<dl class="grid gap-x-10 gap-y-8 sm:grid-cols-2">
				{#each steps as s (s.title)}
					<div>
						<dt class="type-heading">
							<s.icon class="mb-4 block size-5 text-primary" aria-hidden="true" />{s.title}
						</dt>
						<dd class="type-body mt-1 max-w-[42ch] text-muted-foreground">{s.detail}</dd>
					</div>
				{/each}
			</dl>
			</div>
		</div>
	</section>

	<section aria-labelledby="limits-title" class="border-t border-border py-20">
		<div class="mx-auto grid max-w-7xl gap-10 px-4 sm:px-6 lg:grid-cols-12 lg:px-8">
			<h2 id="limits-title" class="type-title lg:col-span-4">What it leaves out</h2>
			<div class="min-w-0 lg:col-span-8"><LeavesOut /></div>
		</div>
	</section>
</main>

<Footer />