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: update the performance tests to use @chainsafe/benchmark #7373

Draft
wants to merge 21 commits into
base: unstable
Choose a base branch
from

Conversation

nazarhussain
Copy link
Contributor

Motivation

Use the @chainsafe/benchmark fork for our performance tests. This will enable to run these tests on multiple JS runtimes.

Description

  • Update the packages
  • Update tests files

Steps to test or reproduce

  • Run all tests

@nazarhussain nazarhussain requested a review from a team as a code owner January 17, 2025 15:51
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.39%. Comparing base (06831cf) to head (58f75d4).
Report is 3 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7373      +/-   ##
============================================
+ Coverage     48.62%   50.39%   +1.77%     
============================================
  Files           603      603              
  Lines         40516    40510       -6     
  Branches       2071     2208     +137     
============================================
+ Hits          19700    20417     +717     
+ Misses        20778    20053     -725     
- Partials         38       40       +2     

Comment on lines +62 to +65

// TODO: Diagnose why this benchmark failing after upgrade
// https://github.com/ChainSafe/lodestar/issues/7380
bench.skip({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only this benchmark is failing, need to troubleshoot in particular later on.

Copy link
Member

@matthewkeil matthewkeil left a comment

Choose a reason for hiding this comment

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

Just a couple small questions but looks good overall

@@ -38,7 +38,7 @@ describe("validate gossip attestation", () => {
state,
bitIndex: i,
});
expect(subnet).to.be.equal(subnet0);
assert.deepEqual(subnet, subnet0);
Copy link
Member

Choose a reason for hiding this comment

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

It seems weird that we need to use assert here...

Comment on lines -37 to -45
it("ArrayBuffer use after structuredClone transfer", () => {
const data = new Uint8Array(32);
data[0] = 1;
expect(data[0]).equals(1);
structuredClone(data, {transfer: [data.buffer]});
// After structuredClone() data is mutated in place to hold an empty ArrayBuffer
expect(data[0]).equals(undefined);
expect(data).deep.equals(new Uint8Array());
});
Copy link
Member

Choose a reason for hiding this comment

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

Did this get moved to a unit test or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looked closely and my observation was that it's not that useful test case. So removed it.

Comment on lines -27 to -32
it("Check is correct", () => {
for (const i of [0, 1, Math.floor(n / 2)]) {
expect(array[i]).to.equal(i, `Wrong value array[${i}]`);
expect(arrayWithProxy[i]).to.equal(i, `Wrong value arrayWithProxy[${i}]`);
}
});
Copy link
Member

Choose a reason for hiding this comment

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

Did this get moved to a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above.

This reverts commit 8a0e51d.
@nflaig
Copy link
Member

nflaig commented Jan 21, 2025

It would be good to figure out #7380 before merging this

@nflaig
Copy link
Member

nflaig commented Jan 21, 2025

there is no benchmark report / comment on this PR, this is no longer supported or just broken?

@nazarhussain
Copy link
Contributor Author

there is no benchmark report / comment on this PR, this is no longer supported or just broken?

Already looking into it.

@nazarhussain nazarhussain marked this pull request as draft January 21, 2025 15:32
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 1770296 Previous: ee9d4fa Ratio
byteArrayEquals 32 24.809 ns/op 53.177 ns/op 0.47
Buffer.compare 32 18.584 ns/op 16.987 ns/op 1.09
byteArrayEquals 1024 913.69 ns/op 1.5764 us/op 0.58
Buffer.compare 1024 26.918 ns/op 25.383 ns/op 1.06
byteArrayEquals 16384 11.619 us/op 25.074 us/op 0.46
Buffer.compare 16384 183.83 ns/op 196.52 ns/op 0.94
byteArrayEquals 123687377 90.488 ms/op 189.55 ms/op 0.48
Buffer.compare 123687377 9.8916 ms/op 6.4664 ms/op 1.53
byteArrayEquals 32 - diff last byte 24.718 ns/op 52.314 ns/op 0.47
Buffer.compare 32 - diff last byte 18.608 ns/op 17.132 ns/op 1.09
byteArrayEquals 1024 - diff last byte 714.15 ns/op 1.5811 us/op 0.45
Buffer.compare 1024 - diff last byte 27.506 ns/op 25.718 ns/op 1.07
byteArrayEquals 16384 - diff last byte 11.262 us/op 25.232 us/op 0.45
Buffer.compare 16384 - diff last byte 210.37 ns/op 199.29 ns/op 1.06
byteArrayEquals 123687377 - diff last byte 99.481 ms/op 186.73 ms/op 0.53
Buffer.compare 123687377 - diff last byte 14.791 ms/op 6.5785 ms/op 2.25
byteArrayEquals 32 - random bytes 3.6440 ns/op 5.1080 ns/op 0.71
Buffer.compare 32 - random bytes 34.621 ns/op 18.559 ns/op 1.87
byteArrayEquals 1024 - random bytes 6.5840 ns/op 5.1010 ns/op 1.29
Buffer.compare 1024 - random bytes 38.936 ns/op 16.933 ns/op 2.30
byteArrayEquals 16384 - random bytes 6.2470 ns/op 5.0850 ns/op 1.23
Buffer.compare 16384 - random bytes 37.749 ns/op 17.016 ns/op 2.22
byteArrayEquals 123687377 - random bytes 5.0100 ns/op 6.3500 ns/op 0.79
Buffer.compare 123687377 - random bytes 41.810 ns/op 18.230 ns/op 2.29

by benchmarkbot/action

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

Successfully merging this pull request may close these issues.

3 participants