Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix busy loops. #3392

Merged
merged 1 commit into from
Jul 1, 2021
Merged

Fix busy loops. #3392

merged 1 commit into from
Jul 1, 2021

Conversation

eskimor
Copy link
Member

@eskimor eskimor commented Jul 1, 2021

Found two busy loops. This fix should bring down CPU usage quite a bit.

@eskimor eskimor added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit. labels Jul 1, 2021
@bkchr bkchr merged commit 3445eeb into master Jul 1, 2021
@bkchr bkchr deleted the rk-busy-loops branch July 1, 2021 06:44
@ordian
Copy link
Member

ordian commented Jul 1, 2021

This fix should bring down CPU usage quite a bit.

I don't expect this to happen. Once FuturesUnordered is empty and yielded None, it won't be polled again until a new element is inserted: https://docs.rs/futures-util/0.3.15/src/futures_util/stream/futures_unordered/mod.rs.html#417.

Unless you use futures.next().fuse() instead of futures.next() in the select loop, which we don't.

@eskimor
Copy link
Member Author

eskimor commented Jul 1, 2021

Wow, I am kind of relieved. Thanks @ordian ! That's actually a sane implementation. So indeed the CPU usage must have gotten down by some other changes, would be interesting what improved matters that much.

@ordian ordian mentioned this pull request Jul 1, 2021
ordian added a commit that referenced this pull request Jul 2, 2021
* master: (21 commits)
  cleanup stream polls (#3397)
  Staking Miner (#3141)
  Companion for Substrate#8953 (#3140)
  Bump version, specs & substrate in prep for v0.9.8 (#3387)
  Fix busy loops. (#3392)
  Minor refactor (#3386)
  add simnet tests (#3381)
  BEEFY: adjust gossip (#3372)
  Companion for #9193 (#3376)
  Companion for Decouple Staking and Election - Part 3: Signed Phase (#2793)
  Ensure that we fetch another collation if the first collation was invalid (#3362)
  Only send one collation per relay parent at a time to validators (#3360)
  disable approval-checking-grandpa on dev chain (#3364)
  Use associated constant for max (#3375)
  Use wasm-builder from git (#3354)
  Squashed 'bridges/' changes from b2099c5..23dda62 (#3369)
  Bump versions & spec_versions (#3368)
  Don't allow bids for a ParaId where there is an overlapping lease period (#3361)
  Companion for upgrade of transaction-payment to pallet macro (#3267)
  Do not allow any crowdloan contributions during the VRF period (#3346)
  ...
ordian added a commit that referenced this pull request Jul 6, 2021
* master: (33 commits)
  Update all weights, add run_all_benches.sh script (#3400)
  Enable over-bridge-messaging in Rococo/Wococo runtime (#3377)
  paras.rs to FRAME V2 (#3403)
  Add XCM Tracing (#3353)
  Use MaxEncodedLen trait from new parity-scale-codec v2.2 (#3412)
  bump a bunch of deps in parity-common (#3402)
  Warn on low connectivity. (#3408)
  origin to frame v2 (#3405)
  Enable logging in the puppet worker (#3411)
  make it easier to dbg stalls (#3351)
  XCM `canonicalize` + `prepend_with` fix (#3269)
  cleanup stream polls (#3397)
  Staking Miner (#3141)
  Companion for Substrate#8953 (#3140)
  Bump version, specs & substrate in prep for v0.9.8 (#3387)
  Fix busy loops. (#3392)
  Minor refactor (#3386)
  add simnet tests (#3381)
  BEEFY: adjust gossip (#3372)
  Companion for #9193 (#3376)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants