-
Notifications
You must be signed in to change notification settings - Fork 524
ParticipationRegistry - StateProof loading methods #3261
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
tsachiherman
merged 6 commits into
algorand:master
from
winder:will/pki-incremental-load
Dec 7, 2021
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6b348cb
WIP: append keys.
winder 02fbb3d
Implement functions.
winder 129e3a0
Add missing license header.
winder 26d2afa
PR Feedback + another test.
winder 3632133
Minor cleanup.
winder 8ad0dd5
Rename GetWithRound to GetForRound.
winder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright (C) 2019-2021 Algorand, Inc. | ||
tsachiherman marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // This file is part of go-algorand | ||
| // | ||
| // go-algorand is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as | ||
| // published by the Free Software Foundation, either version 3 of the | ||
| // License, or (at your option) any later version. | ||
| // | ||
| // go-algorand is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with go-algorand. If not, see <https://www.gnu.org/licenses/>. | ||
|
|
||
| package account | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/algorand/go-algorand/data/basics" | ||
| "github.com/algorand/go-algorand/logging" | ||
| "github.com/algorand/go-algorand/util/db" | ||
| ) | ||
|
|
||
| func benchmarkKeyRegistration(numKeys int, b *testing.B) { | ||
| // setup | ||
| rootDB, err := db.OpenPair(b.Name(), true) | ||
| if err != nil { | ||
| b.Fail() | ||
| } | ||
| registry, err := makeParticipationRegistry(rootDB, logging.TestingLog(b)) | ||
| if err != nil { | ||
| b.Fail() | ||
| } | ||
|
|
||
| // Insert records so that we can t | ||
| b.Run(fmt.Sprintf("KeyInsert_%d", numKeys), func(b *testing.B) { | ||
| for n := 0; n < b.N; n++ { | ||
| for key := 0; key < numKeys; key++ { | ||
| p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3) | ||
| registry.Insert(p) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| // The first call to Register updates the DB. | ||
| b.Run(fmt.Sprintf("KeyRegistered_%d", numKeys), func(b *testing.B) { | ||
| for n := 0; n < b.N; n++ { | ||
| for key := 0; key < numKeys; key++ { | ||
| p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3) | ||
|
|
||
| // Unfortunately we need to repeatedly clear out the registration fields to ensure the | ||
| // db update runs each time this is called. | ||
| record := registry.cache[p.ID()] | ||
| record.EffectiveFirst = 0 | ||
| record.EffectiveLast = 0 | ||
| registry.cache[p.ID()] = record | ||
| registry.Register(p.ID(), 50) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| // The keys should now be updated, so Register is a no-op. | ||
| b.Run(fmt.Sprintf("NoOp_%d", numKeys), func(b *testing.B) { | ||
| for n := 0; n < b.N; n++ { | ||
| for key := 0; key < numKeys; key++ { | ||
| p := makeTestParticipation(key, basics.Round(0), basics.Round(1000000), 3) | ||
| registry.Register(p.ID(), 50) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| func BenchmarkKeyRegistration1(b *testing.B) { benchmarkKeyRegistration(1, b) } | ||
| func BenchmarkKeyRegistration5(b *testing.B) { benchmarkKeyRegistration(5, b) } | ||
| func BenchmarkKeyRegistration10(b *testing.B) { benchmarkKeyRegistration(10, b) } | ||
| func BenchmarkKeyRegistration50(b *testing.B) { benchmarkKeyRegistration(50, b) } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.