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: gradual benchmark pub rand #214

Merged
merged 3 commits into from
Dec 11, 2024
Merged

chore: gradual benchmark pub rand #214

merged 3 commits into from
Dec 11, 2024

Conversation

Lazar955
Copy link
Member

@Lazar955 Lazar955 commented Dec 11, 2024

I had to introduce helper functions to get gradual timing of functions inside commitPubRandPairs.

Findings

Seems that most of the time is spent at GetPubRandList following AddPubRandProofList. As input (NumPubRand) grows we see an increase in time.


Results:

NumPubRand Iterations (b.N) Time per Iteration (ns/op) Time per Iteration (ms) AddPubRandProofList (ns / ms) % AddPubRandProofList CommitPubRandList (ns / ms) % CommitPubRandList GetPubRandList (ns / ms) % GetPubRandList
10 42 27,770,395 27.77 14,544,106 / 14.54 52.43% 1,442,187 / 1.44 5.19% 11,753,113 / 11.75 42.34%
50 16 68,078,846 68.08 15,242,174 / 15.24 22.40% 1,242,602 / 1.24 1.83% 51,516,203 / 51.52 75.69%
100 9 122,120,093 122.12 16,093,750 / 16.09 13.16% 1,271,602 / 1.27 1.04% 104,604,153 / 104.60 85.62%
200 5 231,700,700 231.70 17,093,217 / 17.09 7.37% 1,268,492 / 1.27 0.55% 213,090,417 / 213.09 92.08%
500 2 546,630,958 546.63 20,933,896 / 20.93 3.83% 1,244,730 / 1.24 0.23% 523,769,854 / 523.77 95.52%
1,000 1 1,063,210,125 1,063.21 20,605,666 / 20.61 1.94% 1,276,208 / 1.28 0.12% 1,039,780,500 / 1,039.78 97.72%
5,000 1 5,235,733,292 5,235.73 37,567,250 / 37.57 0.72% 1,250,916 / 1.25 0.02% 5,193,632,875 / 5,193.63 99.15%
10,000 1 10,479,790,875 10,479.79 73,979,584 / 73.98 0.71% 1,314,334 / 1.31 0.01% 10,397,781,458 / 10,397.78 99.07%
25,000 1 26,012,446,417 26,012.45 245,269,750 / 245.27 0.94% 1,380,083 / 1.38 0.01% 25,750,781,708 / 25,750.78 99.06%
50,000 1 52,544,326,750 52,544.33 816,153,875 / 816.15 1.55% 1,354,375 / 1.35 0.03% 51,695,706,875 / 51,695.71 98.41%
75,000 1 79,272,072,959 79,272.07 1,696,296,750 / 1,696.30 2.14% 1,275,250 / 1.28 0.02% 77,517,351,000 / 77,517.35 97.67%
100,000 1 106,582,957,334 106,582.96 2,905,885,458 / 2,905.89 2.73% 1,341,375 / 1.34 0.01% 103,598,760,375 / 103,598.76 97.22%

Closes

@Lazar955 Lazar955 requested a review from gitferry December 11, 2024 11:02
Copy link
Member

@gitferry gitferry left a comment

Choose a reason for hiding this comment

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

Nice work!

@@ -1016,3 +1016,83 @@ func (fp *FinalityProviderInstance) GetFinalityProviderSlashedOrJailedWithRetry(

return slashed, jailed, nil
}

// CommitPubRandTiming - helper struct used to capture times for benchmark
type CommitPubRandTiming struct {
Copy link
Member

Choose a reason for hiding this comment

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

can we move all the helper functionalities to a separate file, maybe benchmark_helper.go?

Comment on lines +278 to +280
b.ReportMetric(float64(totalTiming.GetPubRandListTime.Nanoseconds())/float64(b.N), "ns/GetPubRandList")
b.ReportMetric(float64(totalTiming.AddPubRandProofListTime.Nanoseconds())/float64(b.N), "ns/AddPubRandProofList")
b.ReportMetric(float64(totalTiming.CommitPubRandListTime.Nanoseconds())/float64(b.N), "ns/CommitPubRandList")
Copy link
Member

@gitferry gitferry Dec 11, 2024

Choose a reason for hiding this comment

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

it would be more helpful if we can show the persontage of each part. Does go benchmark support it?

@Lazar955 Lazar955 linked an issue Dec 11, 2024 that may be closed by this pull request
@Lazar955 Lazar955 merged commit e305548 into main Dec 11, 2024
12 checks passed
@Lazar955 Lazar955 deleted the lazar/bench-db branch December 11, 2024 12:16
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.

Benchmark db proof saving time
2 participants