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

chore: run benchmarking utility in devnet environment #3166

Open
wants to merge 32 commits into
base: next
Choose a base branch
from

Conversation

maschad
Copy link
Member

@maschad maschad commented Sep 13, 2024

Fixes TS-639

Summary

This PR introduces devnet benchmarking on master builds, as well as blob transaction deployment testing.

Also previous benchmarking tests are now looped 10 times to have more consistent results.

Checklist

  • All changes are covered by tests (or not applicable)
  • All changes are documented (or not applicable)
  • I reviewed the entire PR myself (preferably, on GH UI)
  • I described all Breaking Changes (or there's none)

Copy link

vercel bot commented Sep 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
create-fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 5:47pm
fuels-template ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 5:47pm
ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 27, 2024 5:47pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
create-fuels-counter-example ⬜️ Ignored (Inspect) Sep 27, 2024 5:47pm

@github-actions github-actions bot added the chore Issue is a chore label Sep 13, 2024
@maschad maschad changed the title chore: run benchmarking utility in devnet environment chore!: run benchmarking utility in devnet environment Sep 13, 2024
@maschad maschad self-assigned this Sep 13, 2024
Copy link

codspeed-hq bot commented Sep 13, 2024

CodSpeed Performance Report

Merging #3166 will improve performances by ×8.1

Comparing mc/test/add-benchmarks-devnet (38920e3) with master (b6a82bc)

Summary

⚡ 2 improvements

🆕 16 new benchmarks
⁉️ 19 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master mc/test/add-benchmarks-devnet Change
⁉️ should successfully execute a contract deploy 101.3 ms N/A N/A
🆕 should successfully execute a contract deploy (x10 times) N/A 99.9 ms N/A
🆕 should successfully execute a contract deploy as blobs N/A 3.7 s N/A
⁉️ should successfully execute a contract mint 95.1 ms N/A N/A
🆕 should successfully execute a contract mint (x10 times) N/A 65.5 ms N/A
⁉️ should successfully execute a contract multi call 71.7 ms N/A N/A
🆕 should successfully execute a contract multi call (x10 times) N/A 72.1 ms N/A
⁉️ should successfully execute a contract read function 67.8 ms N/A N/A
🆕 should successfully execute a contract read function (x10 times) N/A 66.8 ms N/A
⁉️ should successfully write to a contract 65.9 ms N/A N/A
🆕 should successfully write to a contract (x10 times) N/A 65.4 ms N/A
⁉️ should successfully get transaction cost estimate for a batch transfer 47.3 ms N/A N/A
🆕 should successfully get transaction cost estimate for a batch transfer (x10 times) N/A 24.3 ms N/A
🆕 should successfully get transaction cost estimate for a mint (x10 times) N/A 21.7 ms N/A
⁉️ should successfully get transaction cost estimate for a single contract call 22.6 ms N/A N/A
🆕 should successfully get transaction cost estimate for a single contract call (x10 times) N/A 24.6 ms N/A
⁉️ should successfully get transaction cost estimate for a single transfer 26.8 ms N/A N/A
🆕 should successfully get transaction cost estimate for a single transfer (x10 times) N/A 18.4 ms N/A
⁉️ should successfully get transaction cost estimate for multi contract calls 36 ms N/A N/A
🆕 should successfully get transaction cost estimate for multi contract calls (x10 times) N/A 30.8 ms N/A
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

@maschad maschad changed the title chore!: run benchmarking utility in devnet environment chore: run benchmarking utility in devnet environment Sep 13, 2024
Copy link
Contributor

Coverage Report:

Lines Branches Functions Statements
77.23%(+0.06%) 71.1%(-0.71%) 75.77%(+0%) 77.37%(+0.09%)
Changed Files:
Ok File (✨=New File) Lines Branches Functions Statements
🔴 ✨ internal/benchmarks/src/config.ts 0%
(+0%)
0%
(+0%)
0%
(+0%)
0%
(+0%)
🔴 internal/benchmarks/src/contract-interaction.bench.ts 0%
(+0%)
0%
(-100%)
0%
(+0%)
0%
(+0%)
🔴 internal/benchmarks/src/cost-estimation.bench.ts 0%
(+0%)
0%
(-100%)
0%
(+0%)
0%
(+0%)
🔴 internal/benchmarks/src/transaction-results.bench.ts 0%
(+0%)
0%
(-100%)
0%
(+0%)
0%
(+0%)
🔴 internal/benchmarks/src/wallet.bench.ts 0%
(+0%)
0%
(-100%)
0%
(+0%)
0%
(+0%)


export const runBenchmark = (name: string, benchmarkFn: () => Promise<void>) => {
bench(
isDevnet ? name : `${name} (x${iterations} times)`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a big enough value add to justify having a function that we need to wrap every test?

We could just import the iterations value from a config file, that is used against the describe?

Copy link
Member Author

Choose a reason for hiding this comment

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

This arose out of a refactor where we had the isDevnet conditional on each test + adding the iterations per test, but not all tests use the 10 iterations though. So this refactor is the sweet spot I feel.

Copy link
Contributor

@danielbate danielbate Sep 30, 2024

Choose a reason for hiding this comment

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

Just floating ideas, what about:

// config.ts
export const isDevnet = process.env.DEVNET_WALLET_PVT_KEY !== undefined;
export const iterations = isDevnet ? 1 : 10;
// bench.test.ts
import { iterations } from './config.ts';

describe('benchmarks', () => {
  bench('tests a thing', () => {});
  bench('tests another thing', () => {});
}, { iterations });

Then we don't need to augment bench and can use the other config options if we need them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I personally like having the iterations in the name, as it's explicit to why one bench takes for example: 100ms and another takes 1000ms.

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on our sync today I clarified this refactor with @danielbate

Also to corroborate @petertonysmith94 it's actually required to have these distinctions in the test names so that we get accurate reporting on Codspeed, otherwise the statistics will be convoluted (single iterations mixed with multiple iterations)

internal/benchmarks/src/cost-estimation.bench.ts Outdated Show resolved Hide resolved
@maschad maschad marked this pull request as draft September 27, 2024 16:28
@maschad maschad changed the base branch from master to next September 27, 2024 17:27
Copy link
Contributor

@petertonysmith94 petertonysmith94 left a comment

Choose a reason for hiding this comment

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

🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Issue is a chore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run Benchmarking utility in devnet environment
6 participants