|
| 1 | +import Link from "next/link"; |
| 2 | +import { getNodesPayload } from "@/lib/nodes"; |
| 3 | +import type { BenchSample, NodeRow, WorkloadBenchmark } from "@/lib/nodes"; |
| 4 | + |
| 5 | +export const metadata = { |
| 6 | + title: "benchmarks — c0mpute", |
| 7 | + description: |
| 8 | + "Compare c0mpute node hardware and CPU benchmark performance across fibonacci, matrix multiply and BLAKE3 workloads.", |
| 9 | + alternates: { canonical: "https://c0mpute.com/benchmark" }, |
| 10 | +}; |
| 11 | + |
| 12 | +export const dynamic = "force-dynamic"; |
| 13 | + |
| 14 | +const WORKLOADS = [ |
| 15 | + { id: "fib", name: "fibonacci", description: "recursive CPU work and call overhead", unit: "visits/s" }, |
| 16 | + { id: "matmul", name: "matrix multiply", description: "floating point throughput and cache", unit: "FLOP/s" }, |
| 17 | + { id: "hash", name: "BLAKE3 hash", description: "hash throughput and memory bandwidth", unit: "bytes/s" }, |
| 18 | +] as const; |
| 19 | + |
| 20 | +function bestSample(workload: WorkloadBenchmark): BenchSample | undefined { |
| 21 | + return workload.samples.reduce<BenchSample | undefined>( |
| 22 | + (best, sample) => (!best || sample.throughput > best.throughput ? sample : best), |
| 23 | + undefined, |
| 24 | + ); |
| 25 | +} |
| 26 | + |
| 27 | +function formatRate(id: string, rate: number): string { |
| 28 | + if (id === "fib") { |
| 29 | + if (rate >= 1e9) return `${(rate / 1e9).toFixed(2)} G visits/s`; |
| 30 | + if (rate >= 1e6) return `${(rate / 1e6).toFixed(1)} M visits/s`; |
| 31 | + return `${rate.toFixed(0)} visits/s`; |
| 32 | + } |
| 33 | + if (id === "matmul") return `${(rate / 1e9).toFixed(2)} GFLOP/s`; |
| 34 | + return `${(rate / (1024 ** 3)).toFixed(2)} GiB/s`; |
| 35 | +} |
| 36 | + |
| 37 | +function formatRam(bytes: number | null): string { |
| 38 | + return bytes == null ? "—" : `${(bytes / (1024 ** 3)).toFixed(1)} GiB`; |
| 39 | +} |
| 40 | + |
| 41 | +function formatDuration(microseconds: number): string { |
| 42 | + if (microseconds < 1000) return `${microseconds} μs`; |
| 43 | + if (microseconds < 1_000_000) return `${(microseconds / 1000).toFixed(1)} ms`; |
| 44 | + return `${(microseconds / 1_000_000).toFixed(2)} s`; |
| 45 | +} |
| 46 | + |
| 47 | +function formatDate(value: string | null): string { |
| 48 | + if (!value) return "—"; |
| 49 | + const date = new Date(value); |
| 50 | + return Number.isNaN(date.getTime()) |
| 51 | + ? value |
| 52 | + : new Intl.DateTimeFormat("en", { |
| 53 | + dateStyle: "medium", |
| 54 | + timeStyle: "short", |
| 55 | + timeZone: "UTC", |
| 56 | + }).format(date) + " UTC"; |
| 57 | +} |
| 58 | + |
| 59 | +function NodeLabel({ node }: { node: NodeRow }) { |
| 60 | + return ( |
| 61 | + <span className="font-mono"> |
| 62 | + <span className="accent">{node.id}</span> |
| 63 | + <span className="block text-[var(--color-dim)]">{node.cpu || node.class}</span> |
| 64 | + </span> |
| 65 | + ); |
| 66 | +} |
| 67 | + |
| 68 | +function PerformanceTable({ |
| 69 | + workload, |
| 70 | + nodes, |
| 71 | +}: { |
| 72 | + workload: (typeof WORKLOADS)[number]; |
| 73 | + nodes: NodeRow[]; |
| 74 | +}) { |
| 75 | + const rows = nodes.flatMap((node) => { |
| 76 | + const result = node.benchmarks?.[workload.id]; |
| 77 | + const peak = result ? bestSample(result) : undefined; |
| 78 | + const single = result?.samples.find((sample) => sample.threads === 1); |
| 79 | + return peak ? [{ node, result: result!, peak, single }] : []; |
| 80 | + }); |
| 81 | + |
| 82 | + return ( |
| 83 | + <section className="space-y-3" id={workload.id}> |
| 84 | + <header className="space-y-1"> |
| 85 | + <h2 className="text-sm font-semibold">[ {workload.name} ]</h2> |
| 86 | + <p className="text-xs text-[var(--color-dim)]"> |
| 87 | + {workload.description} · higher is better · {workload.unit} |
| 88 | + </p> |
| 89 | + </header> |
| 90 | + {rows.length === 0 ? ( |
| 91 | + <p className="text-sm text-[var(--color-dim)]">No detailed {workload.name} results published yet.</p> |
| 92 | + ) : ( |
| 93 | + <div className="overflow-x-auto border border-[var(--color-rule)] rounded"> |
| 94 | + <table className="w-full min-w-[800px] text-left border-collapse text-xs"> |
| 95 | + <thead className="text-[var(--color-dim)] bg-[var(--color-card)]"> |
| 96 | + <tr> |
| 97 | + <th className="p-3">node / CPU</th> |
| 98 | + <th className="p-3">input</th> |
| 99 | + <th className="p-3">1 thread</th> |
| 100 | + <th className="p-3">best throughput</th> |
| 101 | + <th className="p-3">threads</th> |
| 102 | + <th className="p-3">speedup</th> |
| 103 | + <th className="p-3">run time</th> |
| 104 | + </tr> |
| 105 | + </thead> |
| 106 | + <tbody className="divide-y divide-[var(--color-rule)]"> |
| 107 | + {rows.map(({ node, result, peak, single }) => ( |
| 108 | + <tr key={node.id}> |
| 109 | + <td className="p-3"><NodeLabel node={node} /></td> |
| 110 | + <td className="p-3">{result.params || "—"}</td> |
| 111 | + <td className="p-3">{single ? formatRate(workload.id, single.throughput) : "—"}</td> |
| 112 | + <td className="p-3 accent">{formatRate(workload.id, peak.throughput)}</td> |
| 113 | + <td className="p-3">{peak.threads}</td> |
| 114 | + <td className="p-3">{peak.speedup.toFixed(2)}×</td> |
| 115 | + <td className="p-3">{formatDuration(peak.duration_us)}</td> |
| 116 | + </tr> |
| 117 | + ))} |
| 118 | + </tbody> |
| 119 | + </table> |
| 120 | + </div> |
| 121 | + )} |
| 122 | + </section> |
| 123 | + ); |
| 124 | +} |
| 125 | + |
| 126 | +export default async function BenchmarkPage() { |
| 127 | + const payload = await getNodesPayload(); |
| 128 | + const nodes = payload.nodes; |
| 129 | + const benchmarked = nodes.filter((node) => node.bench_score != null); |
| 130 | + const detailed = nodes.filter((node) => node.benchmarks && Object.keys(node.benchmarks).length > 0); |
| 131 | + |
| 132 | + return ( |
| 133 | + <main className="max-w-5xl mx-auto px-6 py-16 space-y-10"> |
| 134 | + <header className="space-y-2"> |
| 135 | + <div className="flex flex-wrap items-baseline justify-between gap-3"> |
| 136 | + <h1 className="text-2xl font-bold accent">benchmarks</h1> |
| 137 | + <Link href="/nodes" className="text-xs">← live node board</Link> |
| 138 | + </div> |
| 139 | + <p className="comment">// hardware and measured CPU throughput from online nodes</p> |
| 140 | + </header> |
| 141 | + |
| 142 | + <section className="grid gap-4 sm:grid-cols-3"> |
| 143 | + <div className="border border-[var(--color-rule)] rounded p-4"> |
| 144 | + <div className="text-xs text-[var(--color-dim)]">online nodes</div> |
| 145 | + <div className="text-xl accent mt-1">{payload.workers_online.toLocaleString()}</div> |
| 146 | + </div> |
| 147 | + <div className="border border-[var(--color-rule)] rounded p-4"> |
| 148 | + <div className="text-xs text-[var(--color-dim)]">with score</div> |
| 149 | + <div className="text-xl accent mt-1">{benchmarked.length.toLocaleString()}</div> |
| 150 | + </div> |
| 151 | + <div className="border border-[var(--color-rule)] rounded p-4"> |
| 152 | + <div className="text-xs text-[var(--color-dim)]">with detailed results</div> |
| 153 | + <div className="text-xl accent mt-1">{detailed.length.toLocaleString()}</div> |
| 154 | + </div> |
| 155 | + </section> |
| 156 | + |
| 157 | + <section className="space-y-3"> |
| 158 | + <h2 className="text-sm font-semibold">[ hardware ]</h2> |
| 159 | + {nodes.length === 0 ? ( |
| 160 | + <p className="text-sm text-[var(--color-dim)]"> |
| 161 | + {payload.source === "unavailable" ? "The node aggregator is not answering." : "No nodes are online."} |
| 162 | + </p> |
| 163 | + ) : ( |
| 164 | + <div className="overflow-x-auto border border-[var(--color-rule)] rounded"> |
| 165 | + <table className="w-full min-w-[800px] text-left border-collapse text-xs"> |
| 166 | + <thead className="text-[var(--color-dim)] bg-[var(--color-card)]"> |
| 167 | + <tr> |
| 168 | + <th className="p-3">node / CPU model</th> |
| 169 | + <th className="p-3">class</th> |
| 170 | + <th className="p-3">cores</th> |
| 171 | + <th className="p-3">RAM</th> |
| 172 | + <th className="p-3">score</th> |
| 173 | + <th className="p-3">bench run</th> |
| 174 | + </tr> |
| 175 | + </thead> |
| 176 | + <tbody className="divide-y divide-[var(--color-rule)]"> |
| 177 | + {nodes.map((node) => ( |
| 178 | + <tr key={node.id}> |
| 179 | + <td className="p-3"><NodeLabel node={node} /></td> |
| 180 | + <td className="p-3">{node.class}</td> |
| 181 | + <td className="p-3">{node.cores ?? "—"}</td> |
| 182 | + <td className="p-3">{formatRam(node.ram_bytes)}</td> |
| 183 | + <td className="p-3 accent">{node.bench_score?.toLocaleString() ?? "—"}</td> |
| 184 | + <td className="p-3 text-[var(--color-dim)]">{formatDate(node.bench_at)}</td> |
| 185 | + </tr> |
| 186 | + ))} |
| 187 | + </tbody> |
| 188 | + </table> |
| 189 | + </div> |
| 190 | + )} |
| 191 | + {nodes.some((node) => !node.ram_bytes || !node.benchmarks) && ( |
| 192 | + <p className="text-xs text-[var(--color-dim)] leading-6"> |
| 193 | + Some online nodes have older or score-only adverts. Their detailed results and RAM appear after the node updates and publishes a full <code>c0mpute bench</code> report. |
| 194 | + </p> |
| 195 | + )} |
| 196 | + </section> |
| 197 | + |
| 198 | + <section className="space-y-3 border border-[var(--color-rule)] rounded p-4 text-sm leading-7"> |
| 199 | + <h2 className="text-sm font-semibold">[ reading the score ]</h2> |
| 200 | + <p> |
| 201 | + The score combines each node's best fib, matrix multiply and BLAKE3 throughput as a geometric mean against fixed reference rates. <strong>1000</strong> means one reference core's throughput on all three workloads. It is a relative CPU capacity score, not a percentage or an AI model tokens/sec measurement. |
| 202 | + </p> |
| 203 | + <p className="text-[var(--color-dim)]"> |
| 204 | + Fib counts recursive calls per second; matrix multiply reports floating point operations per second; BLAKE3 reports bytes hashed per second. The thread count and speedup show how each workload scales on that machine. c0mpute does not currently publish per-AI-model inference benchmarks here. |
| 205 | + </p> |
| 206 | + </section> |
| 207 | + |
| 208 | + {WORKLOADS.map((workload) => ( |
| 209 | + <PerformanceTable key={workload.id} workload={workload} nodes={nodes} /> |
| 210 | + ))} |
| 211 | + |
| 212 | + <footer className="text-xs text-[var(--color-dim)]"> |
| 213 | + Live data from the public node adverts · <Link href="/api/nodes">JSON API</Link> · refresh with <code>c0mpute bench</code> on a node. |
| 214 | + </footer> |
| 215 | + </main> |
| 216 | + ); |
| 217 | +} |
0 commit comments