Skip to content
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

feat: Make number of worker threads in relayer equal to CPU requested #5499

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ameten
Copy link
Contributor

@ameten ameten commented Feb 18, 2025

Description

Make number of worker threads in relayer equal to CPU requested.

We request 14 CPUs for Relayer pod. This change makes the number of threads in the tokio runtime equal to the number of CPUs we request for Relayer pod so that threads do not compete for CPU resources.

Related issues

Backward compatibility

Yes

Testing

Will be tested in RC

Copy link

changeset-bot bot commented Feb 18, 2025

⚠️ No Changeset found

Latest commit: 99dd3d8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

#[tokio::main(flavor = "multi_thread", worker_threads = 20)]
/// Number of worker threads matches the number of CPU requested for relayer
/// https://github.com/hyperlane-xyz/hyperlane-monorepo/blob/4ddbd60e1f2e150e58dfeab72171c4fa88203db4/typescript/infra/config/environments/mainnet3/agent.ts#L595
#[tokio::main(flavor = "multi_thread", worker_threads = 14)]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just remove worker_threads as it will default to the number of cores for the architecture it's run on
https://docs.rs/tokio/latest/tokio/runtime/struct.Builder.html#default

Suggested change
#[tokio::main(flavor = "multi_thread", worker_threads = 14)]
#[tokio::main(flavor = "multi_thread")]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed in person.

Unfortunately, Relayer pod is not isolated in this manner. Currently, Relayer pod sees 32 CPUs while we limit to 14 CPUs. So, tokio will create 32 threads with the default setting.

from lscpu

CPU(s):                   32
  On-line CPU(s) list:    0-31

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.53%. Comparing base (ebb80f5) to head (99dd3d8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5499   +/-   ##
=======================================
  Coverage   77.53%   77.53%           
=======================================
  Files         103      103           
  Lines        2110     2110           
  Branches      190      190           
=======================================
  Hits         1636     1636           
  Misses        453      453           
  Partials       21       21           
Components Coverage Δ
core 87.80% <ø> (ø)
hooks 79.39% <ø> (ø)
isms 83.68% <ø> (ø)
token 91.27% <ø> (ø)
middlewares 79.80% <ø> (ø)

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.

2 participants