Skip to content

lite: benchmarking tests#4514

Merged
melekes merged 11 commits intomasterfrom
callum/lite-benchmarking
Mar 12, 2020
Merged

lite: benchmarking tests#4514
melekes merged 11 commits intomasterfrom
callum/lite-benchmarking

Conversation

@cmwaters
Copy link
Contributor

@cmwaters cmwaters commented Mar 2, 2020

Closes: #4504 and #4392

Description

Created 4 benchmarking tests testing:

  • Sequential Verification
  • Non Recursive Bisection Verification
  • Recursive Bisection Verification
  • Client Initialization

@melekes let me know what you think


For contributor use:

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer

}
}

func BenchmarkBisection(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

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

979-1005 lines are duplicate of lite2/client_test.go:1007-1034 (from dupl)

}
}

func BenchmarkRecursiveBisection(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

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

1007-1034 lines are duplicate of lite2/client_test.go:979-1005 (from dupl)

)

func BenchmarkSequence(b *testing.B) {
b.N = 10
Copy link
Contributor

Choose a reason for hiding this comment

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

SA3001: should not assign to b.N (from staticcheck)

}

func BenchmarkBisection(b *testing.B) {
b.N = 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

SA3001: should not assign to b.N (from staticcheck)

}

func BenchmarkRecursiveBisection(b *testing.B) {
b.N = 1000
Copy link
Contributor

Choose a reason for hiding this comment

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

SA3001: should not assign to b.N (from staticcheck)

@cmwaters
Copy link
Contributor Author

cmwaters commented Mar 2, 2020

Screen Shot 2020-03-02 at 6 38 58 PM

Here are some preliminary results of the benchmarking. I am still not happy with the amount of variance. So I want to look into it some more. It seems that the two bisection methods are relatively similar in performance when compared with the sequence method

@codecov-io
Copy link

codecov-io commented Mar 2, 2020

Codecov Report

Merging #4514 into master will increase coverage by 0.07%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master   #4514      +/-   ##
=========================================
+ Coverage   65.33%   65.4%   +0.07%     
=========================================
  Files         229     229              
  Lines       20287   20323      +36     
=========================================
+ Hits        13254   13292      +38     
+ Misses       5979    5975       -4     
- Partials     1054    1056       +2
Impacted Files Coverage Δ
lite2/test_helpers.go 98% <100%> (+1.12%) ⬆️
lite2/verifier.go 80.45% <100%> (+0.22%) ⬆️
privval/signer_server.go 91.3% <0%> (-4.35%) ⬇️
blockchain/v2/routine.go 81.81% <0%> (-3.04%) ⬇️
consensus/reactor.go 78.08% <0%> (-0.93%) ⬇️
libs/log/tm_json_logger.go 100% <0%> (ø) ⬆️
consensus/state.go 77.68% <0%> (+0.61%) ⬆️
consensus/replay.go 72.54% <0%> (+0.78%) ⬆️
p2p/pex/pex_reactor.go 83.61% <0%> (+1.69%) ⬆️

@cmwaters cmwaters changed the title lite2: benchmarking tests lite: benchmarking tests Mar 3, 2020
@cmwaters cmwaters added C:light Component: Light S:wip labels Mar 3, 2020
@cmwaters cmwaters self-assigned this Mar 3, 2020
@cmwaters cmwaters marked this pull request as ready for review March 10, 2020 12:18
@cmwaters cmwaters added T:test Type: Tests that need love and removed S:wip labels Mar 10, 2020
}

//
// ################################# BENCHMARKING ######################################
Copy link
Contributor

Choose a reason for hiding this comment

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

let's move into a separate file (client_benchmark_test.go)


func BenchmarkSequence(b *testing.B) {
c := defaultClient()
trustedHeader, _, err := c.fetchHeaderAndValsAtHeight(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we do this with public API?

require.NoError(b, err)
b.ResetTimer()
for n := 0; n < b.N; n++ {
_ = c.sequence(trustedHeader, untrustedHeader, untrustedVals, bTime.Add(1000*time.Minute))
Copy link
Contributor

Choose a reason for hiding this comment

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

can't we do this with public API?

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 guess I just wanted to test just the pure verification method not the entire thing - but I could change it so it uses VerifyHeaderAtHeight() instead

}
}

func BenchmarkClientInitialization(b *testing.B) {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't think we need this per se

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay I will remove it


if !bytes.Equal(untrustedHeader.ValidatorsHash, untrustedVals.Hash()) {
return errors.Errorf("expected new header validators (%X) to match those that were supplied (%X)",
return errors.Errorf("expected new header validators (%X) to match those that were supplied (%X) at height %d",
Copy link
Contributor

Choose a reason for hiding this comment

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

it's the responsibility of the caller to add this info since a) it can be obtained outside this function b) function itself does not change the value of height param

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by this - do you thing adding at heigh %d is unnecessary

Copy link
Contributor

Choose a reason for hiding this comment

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

do you thing adding at heigh %d is unnecessary

yes

Copy link
Contributor Author

@cmwaters cmwaters left a comment

Choose a reason for hiding this comment

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

Will make changes

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

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

@melekes melekes added the S:automerge Automatically merge PR when requirements pass label Mar 12, 2020
@melekes melekes removed the S:automerge Automatically merge PR when requirements pass label Mar 12, 2020
@melekes melekes merged commit 038aff1 into master Mar 12, 2020
@melekes melekes deleted the callum/lite-benchmarking branch March 12, 2020 06:57
cmwaters added a commit that referenced this pull request Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C:light Component: Light T:test Type: Tests that need love

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lite2: non-recursive bisection may be slower than recursive version

4 participants