Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark TTFB Stats #14

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions src/data/[provider]-spark-retrieval-times-summary.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pRetry from 'p-retry';
import { jsonFetcher } from "./json-fetcher.js";
import { getDateXDaysAgo } from "../utils/date-utils.js";
import { parseArgs } from "node:util";

const {
values: { provider }
} = parseArgs({
options: { provider: { type: "string" } }
});

const start = '2024-04-07';
const end = getDateXDaysAgo(1);

const summary = await pRetry(() => jsonFetcher(`https://stats.filspark.com/miner/${provider}/retrieval-times/summary?from=${start}&to=${end}`), { retries: 3 });

process.stdout.write(JSON.stringify(summary));
10 changes: 10 additions & 0 deletions src/data/spark-retrieval-times.json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pRetry from 'p-retry';
import { jsonFetcher } from "./json-fetcher.js";
import { getDateXDaysAgo } from "../utils/date-utils.js";

const start = '2024-04-07';
const end = getDateXDaysAgo(1);

const summary = await pRetry(() => jsonFetcher(`https://stats.filspark.com/retrieval-times/daily?from=${start}&to=${end}`), { retries: 3 });

process.stdout.write(JSON.stringify(summary));
28 changes: 26 additions & 2 deletions src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const SparkNonZeroRates = FileAttachment("./data/spark-rsr-non-zero.json").json(
const SparkMinerRates = FileAttachment("./data/spark-miners-rsr.json").json();
const SparkRetrievalResultCodes = FileAttachment("./data/spark-retrieval-result-codes.json").json();
const SparkMinerRsrSummaries = FileAttachment("./data/spark-miner-rsr-summaries.json").json();
const SparkRetrievalTimes = FileAttachment("./data/spark-retrieval-times.json").json();
```

```js
Expand Down Expand Up @@ -131,8 +132,17 @@ const percentiles = Object.entries(SparkMinerRsrSummaries)

<div class="divider"></div>

<h4>Spark Retrieval Result Codes</h4>
<body>This section shows the Spark Retrieval Result Codes breakdown.</body>

<div class="grid grid-cols-2">
<div>
<h4>Spark Retrieval Result Codes</h4>
<body>This section shows the Spark Retrieval Result Codes breakdown.</body>
</div>
<div>
<h4>Spark Miner Time To First Byte</h4>
<body>This section shows overall median time to first byte for whole network.</body>
</div>
</div>

```js
const mapping = {
Expand Down Expand Up @@ -218,6 +228,20 @@ const tidy = clone(SparkRetrievalResultCodes).flatMap(({ day, rates }) => {
]
})}
</div>
<div class="card">
${Plot.plot({
title: 'Time to First Byte (TTFB)',
x: { type: 'utc', ticks: 'month' },
y: { grid: true, label: 'P50 (ms)' },
marks: [
Plot.lineY(SparkRetrievalTimes, {
x: 'day',
y: 'ttfb_p50',
stroke: "#FFBD3F",
})
]
})}
</div>
</div>

<details>
Expand Down
27 changes: 23 additions & 4 deletions src/provider/[provider].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ title: Storage Provider Summary
```js
import { LineGraph } from "../components/line-graph.js";
import { getDateXDaysAgo } from "../utils/date-utils.js";
const data = FileAttachment(`../data/${observable.params.provider}-spark-rsr-summary.json`).json();

const rsrData = FileAttachment(`../data/${observable.params.provider}-spark-rsr-summary.json`).json();
const ttfbData = FileAttachment(`../data/${observable.params.provider}-spark-retrieval-times-summary.json`).json();

console.log(ttfbData)
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(ttfbData)

```


<div class="hero">
<body><a href="/"><img src="../media/spark-logomark-blue-with-bbox.png" alt="Spark Logo" width="300" /></a><body>
<h2>Dashboard Beta</h2>
Expand All @@ -26,10 +31,24 @@ const end = view(Inputs.date({label: "End", value: getDateXDaysAgo(1) }));

<h3>Stats for ${observable.params.provider}</h3>

<div class="grid grid-cols" style="grid-auto-rows: 500px;">
<div class="grid grid-cols-2" style="grid-auto-rows: 500px;">
<div class="card">${
resize((width) => LineGraph(data, {width, title: "Retrieval Success Rate", start, end }))
resize((width) => LineGraph(rsrData, {width, title: "Retrieval Success Rate", start, end }))
}</div>
<div class="card">
${Plot.plot({
title: 'Time to First Byte (TTFB)',
x: { type: 'utc', ticks: 'month' },
y: { grid: true, label: 'P50 (ms)' },
marks: [
Plot.lineY(ttfbData, {
x: 'day',
y: 'ttfb_p50',
stroke: "#FFBD3F",
})
]
})}
</div>
</div>

<style>
Expand Down Expand Up @@ -73,4 +92,4 @@ const end = view(Inputs.date({label: "End", value: getDateXDaysAgo(1) }));
}
}

</style>
</style>