Skip to content

config: make worker pool configurable and increase default queue size#2542

Merged
blindchaser merged 8 commits intomainfrom
yiren/config-worker-pool
Nov 12, 2025
Merged

config: make worker pool configurable and increase default queue size#2542
blindchaser merged 8 commits intomainfrom
yiren/config-worker-pool

Conversation

@blindchaser
Copy link
Copy Markdown
Contributor

Describe your changes and provide context

  • Adds worker_pool_size and worker_queue_size config options in the app.toml [evm] section
  • Increases default queue from 200 to 1000

Testing performed to validate your change

Add configurable worker_pool_size and worker_queue_size to app.toml

@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 10, 2025

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedNov 12, 2025, 6:05 PM

@codecov
Copy link
Copy Markdown

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.31%. Comparing base (7334276) to head (8bc4670).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (48.75%) is below the target coverage (50.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2542      +/-   ##
==========================================
- Coverage   43.33%   43.31%   -0.02%     
==========================================
  Files        1576     1576              
  Lines      137831   137842      +11     
==========================================
- Hits        59724    59710      -14     
- Misses      72685    72709      +24     
- Partials     5422     5423       +1     
Flag Coverage Δ
sei-chain 31.10% <100.00%> (+0.01%) ⬆️
sei-cosmos 52.55% <ø> (+<0.01%) ⬆️
sei-db 47.63% <ø> (ø)
sei-tendermint 48.74% <ø> (-0.07%) ⬇️
sei-wasmd 46.25% <ø> (ø)
sei-wasmvm 40.37% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
evmrpc/config.go 88.63% <100.00%> (+0.83%) ⬆️
evmrpc/server.go 91.19% <100.00%> (+0.09%) ⬆️
evmrpc/worker_pool.go 88.52% <100.00%> (+0.59%) ⬆️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blindchaser blindchaser force-pushed the yiren/config-worker-pool branch from 580b8d0 to 5461e6a Compare November 10, 2025 21:04
@masih masih self-requested a review November 11, 2025 09:50
Copy link
Copy Markdown
Collaborator

@masih masih left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to write all the tests @blindchaser 🚀

I left a few questions and suggestions. There is one potential blocker in the logic of one of the tests regarding queue size, otherwise LGTM.

@blindchaser blindchaser force-pushed the yiren/config-worker-pool branch from 16968ef to edc038e Compare November 12, 2025 01:24
@blindchaser blindchaser force-pushed the yiren/config-worker-pool branch from edc038e to 7e9c0a0 Compare November 12, 2025 05:09
@blindchaser blindchaser force-pushed the yiren/config-worker-pool branch from 7e9c0a0 to ba02e4a Compare November 12, 2025 06:32
Copy link
Copy Markdown
Collaborator

@masih masih left a comment

Choose a reason for hiding this comment

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

No blockers

evmrpc/config.go Outdated
if workers > 64 {
return 64
}
return workers
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can write this entire body as:

min(64, runtime.NumCPU() * 2)

..at which point, i would recommend against refactoring it into its own function and moving the godoc to be an inline comment that is also reflected in config documentation.

}

// Try to submit many tasks quickly
for i := 0; i < taskCount; i++ {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use for range syntax. Ditto for the loop above and the reminder of the code changes.

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.

addressed

evmrpc/config.go Outdated
RPCStatsInterval time.Duration `mapstructure:"rpc_stats_interval"`

// WorkerPoolSize defines the number of workers in the worker pool.
// Set to 0 to use default (runtime.NumCPU() * 2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At the very least we want to update the documentation to reflect the cap of 64. Ditto in other places.

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.

addressed

// MaxWorkerPoolSize caps the number of workers to prevent excessive
// goroutine creation on high-core machines. Tasks are primarily I/O bound
// (fetching and processing block logs), so 2x CPU cores can be excessive.
MaxWorkerPoolSize = 64
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sad that we are repeating ourselves here regarding what the max is. Can we avoid this repetition?

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.

addressed

@blindchaser blindchaser merged commit 5ae1ad8 into main Nov 12, 2025
56 of 61 checks passed
@blindchaser blindchaser deleted the yiren/config-worker-pool branch November 12, 2025 19:08
blindchaser added a commit that referenced this pull request Nov 21, 2025
…#2542)

- Adds worker_pool_size and worker_queue_size config options in the
app.toml [evm] section
- Increases default queue from 200 to 1000

Add configurable worker_pool_size and worker_queue_size to app.toml
blindchaser added a commit that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants