Skip to content

Improves lute runtime performance when scheduling many threads#706

Merged
Vighnesh-V merged 1 commit intoprimaryfrom
lute-runtime-vecdeque
Jan 6, 2026
Merged

Improves lute runtime performance when scheduling many threads#706
Vighnesh-V merged 1 commit intoprimaryfrom
lute-runtime-vecdeque

Conversation

@Vighnesh-V
Copy link
Copy Markdown
Collaborator

The lute runtime currently schedules coroutines in a std::vector, and we always pop off the first thread in the vector to run. For small numbers of coroutines, this is okay, but when you get to 10k+ this becomes very inefficient as we have to move all the other elements one over O(n). This PR just replaces the std::vector with a Luau::VecDeque, making the pop operation O(1).

I've also included a profiling script that I used to profile lute since I keep forgetting the xctrace incantation - it can be invoked by:

./tools/profile.sh /path/to/.luau(defaults to profile.luau)

@Vighnesh-V Vighnesh-V marked this pull request as ready for review January 6, 2026 22:30
@Vighnesh-V Vighnesh-V force-pushed the lute-runtime-vecdeque branch from b51286a to 0fe89b4 Compare January 6, 2026 22:36
Copy link
Copy Markdown
Member

@vrn-sn vrn-sn left a comment

Choose a reason for hiding this comment

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

Awesome! Curious, do you have any numbers on the improvement?

@Vighnesh-V Vighnesh-V merged commit a179487 into primary Jan 6, 2026
14 checks passed
@Vighnesh-V Vighnesh-V deleted the lute-runtime-vecdeque branch January 6, 2026 23:03
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