Skip to content

performance pass - #121

Open
halfcyan wants to merge 4 commits into
cypress/ch-abstractionfrom
cypress/performance-pass
Open

performance pass#121
halfcyan wants to merge 4 commits into
cypress/ch-abstractionfrom
cypress/performance-pass

Conversation

@halfcyan

Copy link
Copy Markdown
Member

i just wanted to do a larger pass of everything performance-wise since small improvements add up in a system like this


Stack created with GitHub Stacks CLIGive Feedback 💬

@halfcyan

Copy link
Copy Markdown
Member Author

added the benchmarking stuff to see how much this improves stuff and uh. wow.

VM count Before: full scan After: delta construction Approx. speedup
10 116 µs 51 µs 2.3x
100 752 µs 41 µs 18.4x
1,000 5.91 ms 42 µs 140x
10,000 57.83 ms 41 µs 1,412x
100,000 567.92 ms 41 µs 13,795x

@halfcyan
halfcyan force-pushed the cypress/performance-pass branch from 0910116 to 4d14227 Compare August 23, 2026 15:56
@halfcyan

Copy link
Copy Markdown
Member Author

the biggest thing is that the heartbeat resource calc changed from O(VMs) to O(1) which is massive

@TheHeroBrine422 TheHeroBrine422 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.

Overall I like the ideas, but there are minor issues.

On top of this, scheduler_actor.rs is getting really hard to follow. We need better documentation and/or to split the module into several parts.

@korewaChino should likely review the ch_driver changes since I am not super familar with that section of the codebase, although it looks fine to me.

// This could likely be done pretty easily by having two get data messages.
// Option 1: One that creates a session and sends the full data and then only sends diffs after that.
// Option 2: we can have one that sends full data, and then another that only sends data that changes.
// Option 2: One that sends full data, and then another that only sends data that changes.

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.

These todo comments should be removed since this PR does this todo.

.then_some(*vmid)
}))
.collect()
) -> Vec<Ulid> {

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.

This is likely slower then the old implementation?

While the observed slice would have all the vmids, the placement map also has pretty much all the vmids.

So now we have to do an O(n^2) operation every time we run this function, since we do a linear search over every vmid on the agent?

If the placements map was small, then this might be better, but it should be just as big as the observed slice.

The previous solution was O(n) since while we still have to add every placement VM, checking the deduplication is O(1) with a hash set.

}
}

fn reconcile_agent_delta(

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.

the placements hashmap is supposed to be the desired state of the scheduler. If a vm is removed from an agent, we likely should be looking at the placement map to reschedule the agent. not just removing it from the placement map like it doesnt exist.

There should probably be doc comments on the various scheduler data structures to mention this and just generally what the intent of the variables is.

@@ -529,13 +612,33 @@ impl SchedulerActor {
/// - the cache likely needs to be updated automatically when a new vm is scheduled for info like used resources, because otherwise we have to deal with latency on that data we are using
/// and then if someone tries to schedule lets say 10 VMs in a batch, we could end up scheduling them all to the same agent because the metadata hasn't updated.
/// - there are a few solutions for this but they all kinda suck, mostly due to also making sure we deal with latency properly. I am ignoring the issue for now.

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.

this comment is now on the wrong function, and is stale.

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.

2 participants