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

Clustering of processes and distributing messages across the cluster #681

Closed
yorickpeterse opened this issue Jan 14, 2024 · 1 comment
Closed
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module runtime Changes related to the Rust-based runtime library std Changes related to the standard library

Comments

@yorickpeterse
Copy link
Collaborator

Description

The current approach to distributing work is to use a channel, then use e.g. an enum as the message, and have a bunch of processes with a run method that essentially does the following:

fn pub mut run {
  loop {
    match jobs.receive {
      ...
    }
  }
}

While channels certainly have their purpose, it feels a bit redundant to define messages using enum values when processes already have first-class messages.

An alternative is to maintain a list of processes and send them a message directly whenever data is scheduled. This removes the need for an enum, but results in work not being balanced automatically unlike a channel.

It would be nice if we could somehow make this a first-class feature in Inko. The idea is that different instances of a process type can form a "cluster" of sorts. Messages sent to the cluster are then distributed across processes. This would basically act the same way as using channels, just minus the need for an intermediate enum value. Since messages are heap values (due to their variable size), we could in fact reuse channels for this internally.

A hypothetical syntax would be the following:

class async Worker {
  fn async foo(a: Int) { ... }
  fn async bar(b: Int) { ... }
}

let proc1 = Worker {}
let proc2 = Worker {}

# Unsure about the syntax, but this would create the cluster
let cluster = async [proc1, proc2]

cluster.foo(42)
cluster.bar(50)

I'm not sure how we'd distribute work though. For example, in the above case all processes are sleeping, so we'd have to send a message to one to wake it up. This then puts the onus of distributing work on the sender. A proper work-stealing mechanism (as is used by the scheduler itself) would require more substantial changes to how processes are implemented.

Long story short, I want to explore how we can basically turn the current combination of processes and channels into something that's first-class.

Related work

No response

@yorickpeterse yorickpeterse added feature New things to add to Inko, such as a new standard library module compiler Changes related to the compiler std Changes related to the standard library runtime Changes related to the Rust-based runtime library labels Jan 14, 2024
@yorickpeterse yorickpeterse added this to the Future ideas milestone Feb 17, 2024
@yorickpeterse yorickpeterse removed this from the Future ideas milestone Aug 5, 2024
@yorickpeterse
Copy link
Collaborator Author

This isn't something we'll implement any time soon if ever, so I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Changes related to the compiler feature New things to add to Inko, such as a new standard library module runtime Changes related to the Rust-based runtime library std Changes related to the standard library
Projects
None yet
Development

No branches or pull requests

1 participant