-
Notifications
You must be signed in to change notification settings - Fork 493
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
Add ledger.GetBlockAddresses() #2872
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2872 +/- ##
==========================================
- Coverage 47.37% 47.33% -0.04%
==========================================
Files 351 351
Lines 56523 56529 +6
==========================================
- Hits 26776 26760 -16
- Misses 26743 26761 +18
- Partials 3004 3008 +4
Continue to review full report at Codecov.
|
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.
The change looks good - but they don't perform that great. I tested your changes using
go test -v . --run XX --bench BenchmarkBlockEvaluatorRAMNoCrypto -count=10 | grep BenchmarkBlockEvaluatorRAMNoCrypto
and received the following performance metrics on master:
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 945332700 ns/op 18907 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 887004810 ns/op 17741 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 898731697 ns/op 17976 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 905146646 ns/op 18104 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 895749462 ns/op 17916 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 876699177 ns/op 17535 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 889700168 ns/op 17795 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 888446000 ns/op 17770 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 888201852 ns/op 17765 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 916630812 ns/op 18333 ns/eval_validate_tx
compared to the ones from your branch:
BenchmarkBlockEvaluatorRAMNoCrypto-8 1 1016715840 ns/op 20335 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 1 1026562100 ns/op 20533 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 1005568624 ns/op 20112 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 1 1008136765 ns/op 20164 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 1 1016944071 ns/op 20340 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 1016153946 ns/op 20324 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 974119522 ns/op 19483 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 957210924 ns/op 19145 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 879668276 ns/op 17594 ns/eval_validate_tx
BenchmarkBlockEvaluatorRAMNoCrypto-8 2 913933502 ns/op 18279 ns/eval_validate_tx
In the vast of the cases, master
perform better compared to your branch. I would suggest that you'll keep the existing implementation of loadAccounts
as is, and just have your own changes ( you might want to add some comments that it's a code duplication that need to be converged ).
For the purposes of the indexer, we can optimize that code on another task - but there is no reason to introduce a regression to the master.
Would it make sense to add this as a function to SignedTxnInBlock instead of as part of the evaluator? |
I would be ok if we were to add the method to the |
Do we always need all of these accounts available? I suppose the TEAL evaluation needs to read accounts regardless of whether they are modified... If all of these accounts are added to the |
I can't reproduce the difference in performance (perhaps because I'm using the newest version of go). I changed the code slightly. Could you run the benchmark again? |
I'm using
and running the same benchmark again:
is slightly better, but not there yet. |
It might be something to do with the new optimization in go 1.17. https://golang.org/doc/go1.17#compiler How significant is this benchmark anyway? The cost of eval should be dominated by crypto and disk. |
There is no reason to have any performance loss for adding new, non-interfering functionality. I'm sure that the performance loss would have been much more noticeable if we had a benchmark for loadAccounts - but we don't. Given that refactoring this code isn't really what you're after, just rollback the changes in |
ledger/eval.go
Outdated
*out = append( | ||
*out, txn.Sender, txn.Receiver, txn.CloseRemainderTo, txn.AssetSender, | ||
txn.AssetReceiver, txn.AssetCloseTo, txn.FreezeAccount) | ||
*out = append(txn.ApplicationCallTxnFields.Accounts) |
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 think that you meant
*out = append(*out, txn.ApplicationCallTxnFields.Accounts...)
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.
thanks!
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.
looks good to me.
Summary
Indexer needs to know all accounts referenced in a block to be able to read all of them in one batch. This PR creates a function that returns all such account addresses.