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

Move spawning tasks from thread pools to Service's TaskManager for block importing #5647

Merged
merged 25 commits into from
Apr 29, 2020

Conversation

pscott
Copy link
Contributor

@pscott pscott commented Apr 15, 2020

This PR moves the spawning of tasks using a threadpool (from the tx pool and from the import queue) to the service, unifying code, adding on_exit behavior, and allowing stats monitoring via Prometheus.

  • Remove threadpool from import queue
    Remove threadpool from tx pool -- EDIT, cancelled.

refs #5621
polkadot companion: paritytech/polkadot#1035

@pscott pscott added A3-in_progress Pull request is in progress. No review needed at this stage. B0-silent Changes should not be mentioned in any release notes labels Apr 15, 2020
@pscott pscott self-assigned this Apr 15, 2020
@parity-cla-bot
Copy link

It looks like @pscott signed our Contributor License Agreement. 👍

Many thanks,

Parity Technologies CLA Bot

@NikVolf
Copy link
Contributor

NikVolf commented Apr 15, 2020

You probably meant from import queue? Transaction pool code does not seems to be touched.

@pscott
Copy link
Contributor Author

pscott commented Apr 15, 2020

You probably meant from import queue? Transaction pool code does not seems to be touched.

It's WIP, I'll be touching

self.pool.spawn_ok(futures_diagnose::diagnose("validate-transaction", async move {
next :)

EDIT: I've edited the PR name and PR description to be more explicit :)

@pscott pscott changed the title Move spawning tasks from tx pool to Service Move spawning tasks from tx pool and import queue to Service Apr 15, 2020
@pscott pscott changed the title Move spawning tasks from tx pool and import queue to Service Move spawning tasks from thread pools to Service's TaskManager Apr 15, 2020
@tomaka
Copy link
Contributor

tomaka commented Apr 15, 2020

The approach looks good to me so far.

@pscott
Copy link
Contributor Author

pscott commented Apr 15, 2020

So I have not touched the transaction pool thread pool, essentially because we don't want the transaction validation to potentially take up all cores (potential attack vector). For more details, see the comments of #5621 .

@pscott pscott changed the title Move spawning tasks from thread pools to Service's TaskManager Move spawning tasks from thread pools to Service's TaskManager for block importing Apr 15, 2020
@pscott pscott added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Apr 15, 2020
@pscott pscott marked this pull request as ready for review April 15, 2020 17:29
@gnunicorn gnunicorn added this to the 2.0 milestone Apr 16, 2020
@pscott pscott added A3-in_progress Pull request is in progress. No review needed at this stage. and removed A0-please_review Pull request needs code review. labels Apr 17, 2020
@pscott
Copy link
Contributor Author

pscott commented Apr 21, 2020

I think we need #5725 to get merged in before we can solve the current issue :) See this comment

client/service/src/builder.rs Outdated Show resolved Hide resolved
client/service/src/task_manager.rs Outdated Show resolved Hide resolved
@tomaka
Copy link
Contributor

tomaka commented Apr 27, 2020

@gnunicorn So are we still allowed to break the public API (which this PR does)? 😬
I guess it would be acceptable, albeit less great, to revert the TaskType thing. EDIT: ah yeah it breaks the ServiceBuilder too, so this PR is all-or-nothing

@gnunicorn
Copy link
Contributor

So are we still allowed to break the public API (which this PR does)

Yes. Not doing a beta with API stability because that is still unfeasible, but stabilization by focusing on fixing rather than adding features.

@tomaka
Copy link
Contributor

tomaka commented Apr 27, 2020

Please merge master for the Polkadot CI thing to pass

@tomaka
Copy link
Contributor

tomaka commented Apr 27, 2020

Merge master here, not on the Polkadot PR.

@pscott
Copy link
Contributor Author

pscott commented Apr 27, 2020

Merge master here, not on the Polkadot PR.

But I've already merged master here... ?

@tomaka
Copy link
Contributor

tomaka commented Apr 27, 2020

I guess I've misinterpreted the CI errors. Anyway, I've restarted it and there are legitimate errors now.

@pscott
Copy link
Contributor Author

pscott commented Apr 27, 2020

I guess I've misinterpreted the CI errors. Anyway, I've restarted it and there are legitimate errors now.

Yeah I had built polkadot locally but not build for tests. Building for it locally now, will push once it's done :)

@gavofyork
Copy link
Member

@pscott still not building?

@gnunicorn
Copy link
Contributor

tests failing. Lots of

'Receiver::next_message called after `None`',

@tomaka
Copy link
Contributor

tomaka commented Apr 29, 2020

tests failing. Lots of

I don't see this?

Let's merge this now?

@gnunicorn
Copy link
Contributor

yeah, not sure what I saw.

Copy link
Contributor

@gnunicorn gnunicorn left a comment

Choose a reason for hiding this comment

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

lgtm

@gnunicorn gnunicorn merged commit d43fb8e into master Apr 29, 2020
@gnunicorn gnunicorn deleted the scott_move_tx_pool_to_service branch April 29, 2020 16:46
@gnunicorn gnunicorn added B1-clientnoteworthy and removed B0-silent Changes should not be mentioned in any release notes labels Apr 29, 2020
lamafab pushed a commit to lamafab/substrate that referenced this pull request Jun 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants