-
Notifications
You must be signed in to change notification settings - Fork 710
Make txpool test run faster #9382
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
Changes from 2 commits
0096352
48c3102
f84c5ea
99f543a
8ec37c8
77e0280
78ab65d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -547,6 +547,9 @@ public void Commit(IReleaseSpec releaseSpec, IWorldStateTracer stateTracer, bool | |
| { | ||
| FlushToTree(); | ||
| } | ||
|
|
||
| codeFlushTask.GetAwaiter().GetResult(); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is explicit optimization by @benaadams not to do it here, but in the background, then in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? Then what is with the other wait at the end of the same function?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a PR that moves it to end of block processing; though is horribly merged conflicted atm #9012
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So @benaadams is this PR acceptable or makes your solution unachievable and you are confident you will revisit it? |
||
| return; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,7 +256,7 @@ public void should_skip_blob_txs_when_picking_best_persistent_txs_to_broadcast([ | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| bool isBlob = i % 10 == 0; | ||
| transactions[i] = Build.A.Transaction | ||
|
|
@@ -265,7 +265,10 @@ public void should_skip_blob_txs_when_picking_best_persistent_txs_to_broadcast([ | |
| .WithShardBlobTxTypeAndFieldsIfBlobTx() | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
| .TestObject; | ||
| }); | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Broadcast should be thread safe so you can put it under
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least it should be - order doesn't matter here so worth to move to parallelized part and verify it |
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
|
|
||
|
|
@@ -423,14 +426,17 @@ public void should_not_pick_blob_txs_with_MaxFeePerBlobGas_lower_than_CurrentFee | |
| int addedTxsCount = TestItem.PrivateKeys.Length; | ||
| Transaction[] transactions = new Transaction[addedTxsCount]; | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| Parallel.For(0, addedTxsCount, i => | ||
| { | ||
| transactions[i] = Build.A.Transaction | ||
| .WithShardBlobTxTypeAndFields() | ||
| .WithMaxFeePerBlobGas(i.GWei()) | ||
| .SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeys[i]) | ||
|
benaadams marked this conversation as resolved.
|
||
| .TestObject; | ||
| }); | ||
|
|
||
| for (int i = 0; i < addedTxsCount; i++) | ||
| { | ||
|
Comment on lines
+435
to
+436
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| _broadcaster.Broadcast(transactions[i], true); | ||
| } | ||
|
|
||
|
|
||
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.
Using
GetAwaiter().GetResult()can cause thread pool starvation and deadlocks. Consider usingawaitif the method can be made async, or useConfigureAwait(false)to avoid potential deadlocks:codeFlushTask.ConfigureAwait(false).GetAwaiter().GetResult().