Skip to content

Improve scheduler actor - #63

Open
TheHeroBrine422 wants to merge 34 commits into
mainfrom
caleb/fix-scheduler-actor-cache
Open

Improve scheduler actor#63
TheHeroBrine422 wants to merge 34 commits into
mainfrom
caleb/fix-scheduler-actor-cache

Conversation

@TheHeroBrine422

Copy link
Copy Markdown
Contributor

intended changes for this PR

  • improve actor cache
    • currently the actor cache is setup in a way that doesn't really support the scheduler updating it when messages happen. this makes the cache very difficult to use because it can't be relied on for up to date information which means we can barely use it as a cache. a specific issue i hit with this was trying to implement affinity/placement groups. if we rely on the cache data for calculating affinity, we could break the affinity rules due to race conditions.
    • i am replacing the generic version I made with one that is just integrated into the scheduler directly, because otherwise I don't really feel comfortable doing direct modifications to the cache in other segments of the scheduler
    • on top of this, the vm cache arguably needs slightly different code because we basically need the ability to query by either actor id or vmid, and so it needed some sort of modification to support this either way.
    • todo: have messages sent to scheduler directly update the cache
  • Placement groups #28
  • improve scheduling algorithm
    • i realized that currently the scheduling algorithm doesnt consider the resource requirements of the new vm. so for example if an agent had 15/16 vcpus scheduled, and then a new VM was to be scheduled that needed another 16 vcpus, it could theoretically schedule it to that agent. which would be bad

All that is left is testing and review by another maintainer.

this was done for two reasons:
1) the vm and agent actor caches have slightly different requirements,
specifically around keys (actorid vs vmid)
2) the scheduler needs direct control of the cache so the cache can be
updated in response to messages it forwards. being possibly up to 1
second out of date in this data could cause problems. In theory the
scheduler could update the generic cache, but I don't think using a
generic cache if we need to modify it directly anyway really makes
sense.

Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>
scheduler affinity

Signed-off-by: Caleb Jones <caleb@calebgj.io>
…k/odorobo into caleb/fix-scheduler-actor-cache
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Dismissed
Signed-off-by: Caleb Jones <caleb@calebgj.io>
Signed-off-by: Caleb Jones <caleb@calebgj.io>

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
@TheHeroBrine422 TheHeroBrine422 changed the title Caleb/fix scheduler actor cache Improve scheduler actor Jul 16, 2026
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
Comment thread odorobo/src/actors/scheduler_actor.rs Fixed
@TheHeroBrine422
TheHeroBrine422 marked this pull request as ready for review July 16, 2026 20:23
@halfcyan

Copy link
Copy Markdown
Member

i will look at this when i get back home. have you run it through clippy?

halfcyan
halfcyan previously approved these changes Jul 17, 2026
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
korewaChino
korewaChino previously approved these changes Jul 20, 2026
Comment thread odoroboctl/src/cli.rs Outdated
@halfcyan
halfcyan dismissed stale reviews from korewaChino and themself via 2ecbae0 July 31, 2026 06:31
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs
Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
Comment thread odorobo/src/actors/scheduler_actor.rs
halfcyan
halfcyan previously approved these changes Aug 17, 2026
Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
data_cache
.entry(vmid)
.and_modify(|entries| {
if let Some(entry) = entries.iter_mut().find(|entry| {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this code is hard to read.

Comment thread odorobo/src/actors/scheduler_actor.rs Outdated
data_cache.alter(&actor_ref.id(), |_, mut v| {
v.data = data;

v.extended_vm_set.retain(|vmid| v.data.vms.contains(vmid));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this has two issues.

  1. should a vm stay in the extended vm set if we sent CreateVM, then sent GetAgentStatus, GetAgentStatus got there first and so its not in the agent status BUT it will be in a moment when CreateVM is received.

  2. if we do want to reset it entirely, we should just remake the set from the iter directly instead of deleting and then adding things weirdly.

Comment on lines +132 to +142
let cache_is_empty = data_cache.get_mut(&vmid).map_or(false, |mut entries| {
entries.retain(|entry| {
let expired = entry.actor_ref.is_none()
&& now.duration_since(entry.cached_at) >= UNRESOLVED_VM_CACHE_TIMEOUT;
if expired {
removed_agent_ids.push(entry.scheduled_agent_id);
}
!expired
});
entries.is_empty()
});
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.

4 participants