Skip to content

Make txpool test run faster#9382

Merged
asdacap merged 7 commits intomasterfrom
test/make-txpool-test-run-faster
Oct 2, 2025
Merged

Make txpool test run faster#9382
asdacap merged 7 commits intomasterfrom
test/make-txpool-test-run-faster

Conversation

@asdacap
Copy link
Copy Markdown
Contributor

@asdacap asdacap commented Sep 30, 2025

  • Txpool test complete in 12 minute which is 3 time longer than the longest other test. This PR try to make it shorter down to 5 minute.
  • Make txpool test run faster.
  • Make parallel some part of the code.
  • Reduce repetition or private key count on other.
  • Fix randomly failing pyspec test

Types of changes

What types of changes does your code introduce?

  • Optimization

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes: Its all test
  • No

Notes on testing

  • Seems to work.

Copy link
Copy Markdown
Member

@LukaszRozmej LukaszRozmej left a comment

Choose a reason for hiding this comment

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

@marcindsobczak could you take a look?

Comment on lines +550 to +552

codeFlushTask.GetAwaiter().GetResult();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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 Commit you have wait for the one from previous block.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

Comment on lines +270 to +271
for (int i = 0; i < addedTxsCount; i++)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Broadcast should be thread safe so you can put it under Parallel.For

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Comment on lines +438 to +439
for (int i = 0; i < addedTxsCount; i++)
{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes test execution time in the transaction pool test suite by implementing parallelization and reducing test repetition. The goal is to reduce test runtime from 12 minutes to approximately 5 minutes.

Key Changes:

  • Parallelized transaction creation in multiple test methods using Parallel.For and Parallel.ForEach
  • Reduced the number of private keys used in blob transaction tests from full TestItem.PrivateKeys array to first 64 elements
  • Decreased test repetition count from 10 to 2 for nonce manager tests

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
TxPoolTests.Blobs.cs Parallelized transaction creation and reduced private key count for blob indexing tests
TxBroadcasterTests.cs Parallelized transaction creation in two broadcast test methods
NonceManagerTests.cs Reduced test repetition count from 10 to 2 for nonce locking test
StateProvider.cs Added synchronous wait for code flush task completion
Comments suppressed due to low confidence (1)

src/Nethermind/Nethermind.TxPool.Test/TxBroadcasterTests.cs:1

  • Parallel transaction creation may cause race conditions when accessing the shared _ethereumEcdsa instance. Consider using thread-safe alternatives or creating separate ECDSA instances per thread.
// SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited

FlushToTree();
}

codeFlushTask.GetAwaiter().GetResult();
Copy link

Copilot AI Oct 1, 2025

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 using await if the method can be made async, or use ConfigureAwait(false) to avoid potential deadlocks: codeFlushTask.ConfigureAwait(false).GetAwaiter().GetResult().

Copilot uses AI. Check for mistakes.
@LukaszRozmej
Copy link
Copy Markdown
Member

@asdacap should you experiment with parallelizing broadcast and txpool usage in tests?

@asdacap
Copy link
Copy Markdown
Contributor Author

asdacap commented Oct 2, 2025

I just want faster test 😢.

@asdacap asdacap merged commit ab26f54 into master Oct 2, 2025
79 checks passed
@asdacap asdacap deleted the test/make-txpool-test-run-faster branch October 2, 2025 13:02
stdevMac pushed a commit that referenced this pull request Oct 5, 2025
* Make txpool test run faster

* Fix randomly failing pyspec test

* parallelize BroadcasterTests more

* Even more

* Parallelize more

* Remove this part

* more parallel

---------

Co-authored-by: lukasz.rozmej <lukasz.rozmej@gmail.com>
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.

5 participants