-
Notifications
You must be signed in to change notification settings - Fork 741
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
Conversation
x/merkledb/db_test.go
Outdated
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)) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
x/merkledb/helpers_test.go
Outdated
"github.com/ava-labs/avalanchego/utils/maybe" | ||
) | ||
|
||
func protoProofsEqual(proof1, proof2 *pb.Proof) bool { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Co-authored-by: Dan Laine <daniel.laine@avalabs.org> Signed-off-by: David Boehm <91908103+dboehm-avalabs@users.noreply.github.com>
This reverts commit ff7c4cd.
There was a problem hiding this 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
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>
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