Skip to content

Conversation

@pathoam
Copy link

@pathoam pathoam commented Dec 7, 2025

Change Type

  • perf: Performance improvement.

Description

Replace list with collections.deque for the scheduler's wait queue. list.pop(0) is O(n) because it shifts all elements; deque.popleft() is O(1).

Key Changes

  1. Changed _wait_queue type from List to Deque
  2. Changed .pop(0) to .popleft() in admit_requests()
  3. Updated imports accordingly

@pathoam pathoam requested a review from a team December 7, 2025 23:57
@pathoam pathoam changed the title perf(scheduler): use deque for O(1) queue operations perf(scheduler): use deque for O(1) queue operations Dec 8, 2025
@pathoam
Copy link
Author

pathoam commented Dec 8, 2025

lint was initially blocked because I put a space at the beginning of the pr title by accident. should work now

@yuhao-zh yuhao-zh changed the title perf(scheduler): use deque for O(1) queue operations perf(scheduler): use deque for o(1) queue operations Dec 8, 2025
@yuhao-zh
Copy link
Collaborator

yuhao-zh commented Dec 8, 2025

Thanks for your contribution,I will review your code shortly and then test its performance.
Merge will be soon.

@pathoam
Copy link
Author

pathoam commented Dec 10, 2025

@yuhao-zh
following up on this, have you had a chance to review?

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