Skip to content

Hypergraph-based system execution scheduler.#8

Draft
Kuba663 wants to merge 16 commits into
CleanroomMC:mainfrom
Kuba663:devel/scheduler
Draft

Hypergraph-based system execution scheduler.#8
Kuba663 wants to merge 16 commits into
CleanroomMC:mainfrom
Kuba663:devel/scheduler

Conversation

@Kuba663

@Kuba663 Kuba663 commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

In this PR, I implemented a system scheduler that automatically decides which tasks can be ran in parallel.
The Scheduler works as follows:

  1. A hypergraph is created, where the systems are vertices and their dependencies (components and resources) are edges.
  2. A graph is created where each vertex is connected to all of the vertices that do not share an edge in the hypergraph.
  3. The resulting disjointed graph is colored.
  4. Vertices of each color are added topriority queues (one for each color).
  5. The priority queue array is used to build a directed acyclic graph (this is not complete yet).

TODO:

  • Make the Scheduler actually build the DAG.
  • Write a more efficient Hypergraph implementation, the current one uses two multimaps.
  • Handle systems deending on eachother.
  • Use a Fibonacci Heap in the graph coloring function as it's faster.
  • Refactor the coding style, as it's not appropriate.
  • Write Unit Tests for Hypergraphs and Graph Coloring.
  • Integrate into Kirino, currently it's just a thing that exists and does nothing.

@Kuba663

Kuba663 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator Author

I'm giving up on the Fibonacci Heap for now as I don't know how to implement removal without key decreases.

@Kuba663

Kuba663 commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Bottleneck related to systems depending on eachother, currently the scheduler handles them by simply treating them as sharing a hyperedge, however this can potentially cause problems in the coloring part, as it's not guaranteed that depending systems will have the same color. A possible solution would be collapsing dependent vertex chains into single vertices representing sequential execution of several systems. This however raises another problem related to the vertices in two different branches that are required for executing another system sharing an hyperedgeedge, which could cause potential race conditions. The solution would require creating a separate system for dealing with dependencies that treats system/system relation differently from the typical system/resource relation.
Presented below is an ilustration showcasing the problem. The vertices cannot be collapsed due to a shared hyperedge representing a shared read-write/write-write to a resource (that is: a Resource or a Component).
image
Yet another alternative solution to this problem would be collapsing all vertices under the same hyperedges into a single vertex, until only vertices representing systems completely independent of eachother remain.

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

Successfully merging this pull request may close these issues.

1 participant