Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated insert_sleeping_task function to try to improve the complexity time #781

Closed
wants to merge 1 commit into from

Conversation

JimmyL04
Copy link

@JimmyL04 JimmyL04 commented Oct 4, 2024

This PR tried improves the time complexity of the ControlTaskQueue::insert_sleeping_task_ function by replacing the sorted linked list used for delayed tasks with a std::priority_queue.

Key Improvements:

  • The previous implementation used a sorted linked list, leading to O(N) insertion time due to the need to traverse the list to find the correct insertion point.
  • The new implementation uses a priority queue (min-heap), reducing the insertion time complexity to O(log N) while maintaining efficient pop operations.

Changes Made:

  • Replaced the sorted linked list with std::priority_queue, simplifying the logic for task insertion.
  • The priority queue is configured to prioritize tasks based on their effective_deadline_, ensuring the task with the earliest deadline is always at the top.
  • The overall complexity for inserting tasks is now O(log N), providing better scalability as the number of tasks grows.

Copy link

github-actions bot commented Oct 4, 2024

🤖 Upon creation, pull request description does not have a link to an issue. If there is a related issue, please add it to the description using any of the supported formats.

@github-actions github-actions bot added the contribution A pull-request by someone else except maintainers label Oct 4, 2024
@gavv
Copy link
Member

gavv commented Oct 7, 2024

Hi,

Besides that it doesn't compile and doesn't have actual code (?), please check out discussion and requirements in the original issue for why std::priority_queue is not an option here: #379

@gavv gavv closed this Oct 7, 2024
@gavv gavv added invalid and removed contribution A pull-request by someone else except maintainers labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants