Skip to content

Merkledb Attempt to reduce test runtime #1990

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

Merged
merged 34 commits into from
Sep 12, 2023
Merged

Conversation

dboehm-avalabs
Copy link
Contributor

@dboehm-avalabs dboehm-avalabs commented Sep 8, 2023

MerkleDB package often times out during tests, so make some adjustments to reduce total runtime. Improvements come from turning several long running randomized tests into fuzz tests

r := rand.New(rand.NewSource(now)) // #nosec G404
runRandDBTest(require, r, generateInitialValues(require, r, initialValues, updates, checkHashProbability))
func Fuzz_MerkleDB_RandomCases(f *testing.F) {
f.Add(int64(0), uint16(1000))
Copy link

Choose a reason for hiding this comment

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

Why do we add these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the CI setup is, but Fuzz tests don't run by default when you just do go test unless they have some base corpus added. This, and any others we may want to add, ensure that this test runs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, looking at the CI, we do separately run the fuzz tests anyway, so it isn't strictly needed.

"github.com/ava-labs/avalanchego/utils/maybe"
)

func protoProofsEqual(proof1, proof2 *pb.Proof) bool {
Copy link

Choose a reason for hiding this comment

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

I feel like we should just use require.Equal. I'd rather the UT take a bit longer than have to maintain this additional code, and I think it's more readable to just use require.Equal in the tests.

Copy link
Contributor Author

@dboehm-avalabs dboehm-avalabs Sep 8, 2023

Choose a reason for hiding this comment

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

It makes the tests take 4x as long though and we are hitting the timeout, so we either need to speed up existing tests or start removing tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Run With Normal Equals vs
Run With Custom Equals

This is just one run and I'm not sure what the variance is but it saves:
~7 seconds on ARM
~3 seconds on Ubuntu
~8 seconds on Mac
~13 seconds on Windows

Average savings is about ~30% of the total run time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you feel that strongly about it, I'll make them fuzz tests instead and still use require.equal

@danlaine danlaine added testing This primarily focuses on testing ci This focuses on changes to the CI process merkledb labels Sep 8, 2023
Copy link

@danlaine danlaine left a comment

Choose a reason for hiding this comment

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

2 nits otherwise lgtm

dboehm-avalabs and others added 4 commits September 11, 2023 10:55
Co-authored-by: Dan Laine <daniel.laine@avalabs.org>
Signed-off-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
Co-authored-by: Dan Laine <daniel.laine@avalabs.org>
Signed-off-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
@danlaine danlaine merged commit 05af816 into dev Sep 12, 2023
@danlaine danlaine deleted the MerkleDBReduceTestRuntime branch September 12, 2023 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci This focuses on changes to the CI process merkledb testing This primarily focuses on testing
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants