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

Upgrade the task scheduler to stable Tokio #75

Open
drunkirishcoder opened this issue Apr 8, 2020 · 5 comments · May be fixed by #138
Open

Upgrade the task scheduler to stable Tokio #75

drunkirishcoder opened this issue Apr 8, 2020 · 5 comments · May be fixed by #138
Assignees
Labels
enhancement New feature or request

Comments

@drunkirishcoder
Copy link
Contributor

drunkirishcoder commented Apr 8, 2020

Background

Capsule v0.1.0 uses a customized task scheduler leveraging a preview version of Tokio and futures. We need to upgrade to the stable releases of futures and Tokio now that they are available.

Problem

Tokio lib has gone through a major project restructure. The components we leveraged in building the custom task scheduler are not accessible from outside the Tokio crate anymore. Instead we have to use the default threadpool scheduler if we want to avoid writing our own task scheduling. To move off of the preview releases, the current scheduler has to be reimplemented.

Proposal

The current threading model Capsule uses is a run-to-completion model, where each thread is responsible for reading a batch of packets from the RX queue, feed the batch through the combinator pipeline for processing, send them out through the TX queue, rinse and repeat.

Instead, we can move to a threadpool-based model where a single receiving thread is used for reading batches of packets from the RX queue, and queues up each batch as a task that the threads in a threadpool can then pick up and process.

This will be a major breaking change. And we will need to measure and compare the performance of the two threading models.

@drunkirishcoder drunkirishcoder added the enhancement New feature or request label Apr 8, 2020
@zeeshanlakhani zeeshanlakhani changed the title upgrade the task scheduler to stable Tokio Upgrade the task scheduler to stable Tokio Apr 8, 2020
@drunkirishcoder drunkirishcoder self-assigned this Apr 8, 2020
@rohitjoshi
Copy link

May be switch to smol

@drunkirishcoder
Copy link
Contributor Author

@rohitjoshi interesting suggestion. I really like the simplicity of smol a lot after briefly looking it over. Going to read through the blog posts to get a better understanding of it. Thank you for bring this up. We will definitely add it to our consideration.

@ratnadeepb
Copy link

Have you guys figured out a way you would like to move forward with this? I have spent some time looking at your Runtime code and I was wondering if I might be able to provide some help! (Disclaimer: I am relatively new to Rust and especially async Rust)

@zeeshanlakhani
Copy link
Member

@ratnadeepb I'll let @drunkirishcoder say more, but we do already have a new, updated run to completion model that's currently WIP. We've just been a bit busy with other projects, but plan to finish up the work soon. Once it's up for review however, we could def use some review, testing, etc...

@drunkirishcoder drunkirishcoder linked a pull request Mar 30, 2021 that will close this issue
2 tasks
@JakkuSakura
Copy link
Contributor

I have implemented a runtime agnostic version of capsule, leveraging glommio and tokio 1.0 to better fit my requirements. It is ugly but basically worked. Hope capsule 0.2.0 give the proper api to replace the runtime more easily

@zeeshanlakhani zeeshanlakhani linked a pull request Apr 9, 2021 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging a pull request may close this issue.

5 participants