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

vine: priority queue implementation #3919

Open
wants to merge 50 commits into
base: master
Choose a base branch
from

Conversation

JinZhou5042
Copy link
Member

Proposed Changes

Give an overall description of the changes, along with the context and motivation.
Mention relevant issues and pull requests as needed.

Merge Checklist

The following items must be completed before PRs can be merge.
Check these off to verify you have completed all steps.

  • make test Run local tests prior to pushing.
  • make format Format source code to comply with lint policies. Note that some lint errors can only be resolved manually (e.g., Python)
  • make lint Run lint on source code prior to pushing.
  • Manual Update Update the manual to reflect user-visible changes.
  • Type Labels Select a github label for the type: bugfix, enhancement, etc.
  • Product Labels Select a github label for the product: TaskVine, Makeflow, etc.
  • PR RTM Mark your PR as ready to merge.

@JinZhou5042 JinZhou5042 marked this pull request as draft August 20, 2024 15:19
@JinZhou5042
Copy link
Member Author

JinZhou5042 commented Aug 22, 2024

To sum up, the manager resets the cursor in two conditions:

  • worker connection
  • task done (file recovery always comes with a recovery task done)

And the data structure resets the cursor in four cases:

  • delete/insert an element prior/equal to the cursor

The manager always resets the cursor to the head, while the data structure always resets to the insert/deletion point - 1.

Copy link
Member

@dthain dthain left a comment

Choose a reason for hiding this comment

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

  • Is it really necessary to have three iterators in priority_queue.h? Why not just one?
  • Add a test dttools/test/TR_priority_queue.sh that exercises the priority queue independently of taskvine. The data structure must be absolutely bulletproof.
  • Add a big enormous comment at the beginning of start_one_task that explains why we are iterating over the queue in this way, and where/why the iterator should be reset.

dttools/src/priority_queue.c Outdated Show resolved Hide resolved
dttools/src/priority_queue.c Outdated Show resolved Hide resolved
dttools/src/priority_queue.c Outdated Show resolved Hide resolved
taskvine/src/manager/vine_manager.c Outdated Show resolved Hide resolved
taskvine/src/manager/vine_manager.c Outdated Show resolved Hide resolved
@JinZhou5042
Copy link
Member Author

JinZhou5042 commented Oct 17, 2024

@btovar @colinthomas-z80 Could you please take a look at this PR and see if there is anything that is potentially causing any issues? Your suggestions would be greatly helpful as I am modifying the underlying data structure, and there may be areas where I am not very careful.

@dthain
Copy link
Member

dthain commented Oct 24, 2024

@btovar please review

dttools/src/priority_queue.c Outdated Show resolved Hide resolved
dttools/src/priority_queue.c Outdated Show resolved Hide resolved
dttools/src/priority_queue.c Show resolved Hide resolved
dttools/src/priority_queue.h Outdated Show resolved Hide resolved
@param priority The specified priority with the given object.
@return The idex of data if the push succeeded, -1 on failure.
*/
int priority_queue_push_upward(struct priority_queue *pq, void *data, double priority);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want two versions of push. If the order of two elements with the same priority matters, then they should not have the same priority.

Copy link
Member Author

@JinZhou5042 JinZhou5042 Nov 4, 2024

Choose a reason for hiding this comment

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

@btovar This version of push came from a discussion with @dthain, the idea was that when a task is resubmitted given previous resource exhaustion, we want it to be dispatched as soon as possible in order to get more resources allocated to it. For those big tasks, we don't want to change their assigned priorities, but pushing them upward of those with the same priority is likely to get a bigger chance of scheduling earlier.

dttools/src/priority_queue.h Outdated Show resolved Hide resolved
@param index The index of the element to get.
@return The pointer to the element if any, failure otherwise
*/
void *priority_queue_get_element(struct priority_queue *pq, int index);
Copy link
Member

Choose a reason for hiding this comment

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

peek_at? Also, allow index 0 and do a +1 internally. Otherwise the abstraction is leaking.

Copy link
Member Author

Choose a reason for hiding this comment

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

@btovar The index 0 is taken by a sentinel element, I think its ambiguous if both 0 and 1 index are allowed and return the same value?

dttools/src/priority_queue.c Outdated Show resolved Hide resolved
dttools/src/priority_queue.h Outdated Show resolved Hide resolved
taskvine/src/manager/vine_manager.c Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants