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

Explore: Task scheduling API #110

Open
casperisfine opened this issue May 6, 2024 · 3 comments
Open

Explore: Task scheduling API #110

casperisfine opened this issue May 6, 2024 · 3 comments

Comments

@casperisfine
Copy link
Contributor

A not so uncommon optimization technique used by apps, it to use a background thread to regularly poll some data and keep a copy always accessible in memory.

Or similarly, it's not uncommon to have a background thread collect and emit metrics at common interval.

With Pitchfork this isn't ideal because you have to be very careful that all background threads are either shutdown or at a safe point when a worker is promoted or when the mold forks a new child.

Idea

Maybe not for 100% of use case, but I believe that in many cases such threads don't actually need to be in the mold nor workers, and could instead be in a separate process.

They also very often don't need an actual dedicated thread, they simply sleep in a loop to perform some action at regular interval.

As such, if we provided a task scheduling API similar to rufus-scheduler (e.g. every 10s), we could run these tasks on a single thread (or a low number of threads) in a dedicated worker, that's never used for promotion, hence for which forking at random points isn't a concern.

For the tasks that need to expose data to workers, they can use a variety of IPC solutions, such as a local key value store, shared memory (with Raindrops), write into file, sqlite3 database etc etc.

@nlicalzi
Copy link

nlicalzi commented May 6, 2024

Upvoting that this is important, and happy to help where needed/possible

@danmayer
Copy link

danmayer commented May 6, 2024

yes, this could be very useful for a number of things the caching folk are interested in.

@elaineylchan
Copy link

Hi @casperisfine hope you are well, want to just ensure that this ticket is still on your radar aiming towards end of the month? :)

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

No branches or pull requests

4 participants