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
2 changes: 2 additions & 0 deletions benchmarks/token-quote-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ dimensions:
- { value: virtuals, label: Virtuals }
- { value: four-meme, label: Four.meme }
- { value: pons, label: Pons }
- { value: moonshot, label: Moonshot }
- { value: meteora-dbc, label: Meteora DBC }
chain:
- { value: all, label: All chains }
- { value: solana, label: Solana }
Expand Down
16 changes: 14 additions & 2 deletions src/app/benchmarks/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ export default async function BenchmarkPage({
// sub-100 ms after one warm-up.
const aggregate = await getBenchmark(slug);
if (!aggregate) notFound();
const chainOptions = aggregate.dimensions?.chain ?? [];
const chainsWithData = new Set<string>(Object.keys(aggregate.providersPerChain ?? {}));
const chainOptions =
chainsWithData.size === 0
? (aggregate.dimensions?.chain ?? [])
: (aggregate.dimensions?.chain ?? []).filter(
(c) => c.value === "all" || chainsWithData.has(c.value),
);
// Drop declared regions that the harness doesn't actually emit data for
// (e.g. metadata-coverage lists sgp in the spec but only ever publishes
// region="unknown"). Without this the picker offers a tab that 404s on
Expand Down Expand Up @@ -230,7 +236,13 @@ export default async function BenchmarkPage({
(r) => r.value === "all" || regionsWithData.has(r.value),
);
const kindOptions = aggregate.dimensions?.kind ?? [];
const venueOptions = aggregate.dimensions?.venue ?? [];
const venuesWithData = new Set<string>(aggregate.extras?.venuesWithData ?? []);
const venueOptions =
venuesWithData.size === 0
? (aggregate.dimensions?.venue ?? [])
: (aggregate.dimensions?.venue ?? []).filter(
(v) => v.value === "all" || venuesWithData.has(v.value),
);
const chain = chainOptions[0]?.value ?? null;
const region = regionOptions[0]?.value ?? null;
const kind = kindOptions[0]?.value ?? null;
Expand Down
25 changes: 22 additions & 3 deletions src/lib/materialize/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,11 @@ export async function specToBenchmark(
// Exact per-cell rankings (chain × region) from the spec's single
// grouped matrix query. Failures are tolerated: badge/product
// surfaces fall back to the coarser bestPerChain path.
const cellRanks = !isFiltered ? await tryLoadCellRanks(spec) : undefined;
const cellRankResult = !isFiltered ? await tryLoadCellRanks(spec) : undefined;
const cellRanks = cellRankResult?.ranks;
if (cellRankResult?.venuesWithData?.length) {
live.extras.venuesWithData = cellRankResult.venuesWithData;
}

// Per-provider sample-health classification. When the spec declares
// expected_n, every live provider gets `dataConfidence` (healthy /
Expand Down Expand Up @@ -434,9 +438,14 @@ export function propagateNullsToCoarser(
* the matrix is unfiltered PromQL, so stray series (retired providers,
* staging labels) must not leak into rankings.
*/
type CellRankResult = {
ranks: Record<string, CellRankEntry[]>;
venuesWithData: string[];
};

async function tryLoadCellRanks(
spec: Spec,
): Promise<Record<string, CellRankEntry[]> | undefined> {
): Promise<CellRankResult | undefined> {
if (!spec.rank_matrix_query) return undefined;
const url = spec.prometheus?.url ?? process.env.PROMETHEUS_URL;
if (!url) return undefined;
Expand All @@ -451,6 +460,12 @@ async function tryLoadCellRanks(
// Canonical dimension value by lowercase, so a harness emitting
// `chain="Base"` still maps onto the declared `base` value instead
// of silently dropping the cell.
const venueByLower = new Map(
(spec.dimensions?.venue ?? [])
.filter((v) => v.value !== "all")
.map((v) => [v.value.toLowerCase(), v.value] as const),
);
const venuesWithDataSet = new Set<string>();
const chainByLower = new Map(
(spec.dimensions?.chain ?? [])
.filter((c) => c.value !== "all")
Expand Down Expand Up @@ -480,6 +495,10 @@ async function tryLoadCellRanks(
if (regionByLower.size > 0 && !region) continue;
const v = Number(sample.value[1]);
if (!Number.isFinite(v) || v <= 0) continue;
if (venueByLower.size > 0 && sample.metric.venue) {
const venue = venueByLower.get(sample.metric.venue.toLowerCase());
if (venue) venuesWithDataSet.add(venue);
}
const key = `${chain ?? "all"}|${region ?? "all"}`;
const cell = acc.get(key) ?? new Map<string, number[]>();
const vals = cell.get(slug) ?? [];
Expand Down Expand Up @@ -552,7 +571,7 @@ async function tryLoadCellRanks(
(region) => `all|${region}`,
);
}
return out;
return { ranks: out, venuesWithData: [...venuesWithDataSet] };
} catch (e) {
console.warn(
`cellRanks skip: ${spec.slug} matrix query failed: ${e instanceof Error ? e.message : String(e)}`,
Expand Down
1 change: 1 addition & 0 deletions src/lib/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const ResultExtrasSchema = z.object({
.record(z.string(), z.record(z.string(), Series24hSchema))
.optional(),
regions: z.record(z.string(), z.array(RegionPointSchema)),
venuesWithData: z.array(z.string()).optional(),
});

const MetricPanelSchema = z.object({
Expand Down
2 changes: 2 additions & 0 deletions src/types/benchmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export type ResultExtras = {
/** Per-region 30d series. */
seriesByRegion30d?: Record<string, Record<string, Series24h>>;
regions: Record<string, RegionPoint[]>;
/** Venue dimension values that have actual Prom data in the current window. */
venuesWithData?: string[];
};

export type Benchmark = {
Expand Down
Loading