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

Randomize tasks #548

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Randomize tasks #548

wants to merge 2 commits into from

Conversation

DougBurke
Copy link
Member

This is my attempt to address #397 but it's only partial (it doesn't select a random task, it's just that tasks that get added may be randomized, but this does not randomize the whole set).

It is also not turned on by default. To run you would need to change

foo = TaskRunner()

to

foo = TaskRunner(randomize_insert=True)

to test this out.

This is an attempt to address cxcsds#397 but it is only a partial
implementation:

a) you have to opt into this when creating the TaskRunner instance,
   TaskRunner(randomize_insert=True)
   {or you could change the .randomize_insert value of the object
   to True, before calling run_tasks()}

b) this is not a full randomization: that is, we do not randomly
   select from all the available tasks, but we only randomize
   from the set of tasks when we can add a new set of tasks, which
   is only going to really be useful when a barrier is processed,
   allowing a new set of tasks to be added to the queue. For
   simple cases, when running a single task adds a new task to the
   queue, we do not benefit.

   It also may be completely unhelpful, as it depends on what
   JoinableQueue.get does to select the next task, which appears
   to be under-documented.
@DougBurke
Copy link
Member Author

@kglotfelty - if you're bored you could see if this helps srcflux, but my bet is it won't.

@kglotfelty
Copy link
Member

I tried this with srcflux, and even after adding randomize_input=True , it's still running things in the order they were added.

@DougBurke
Copy link
Member Author

Ta for checking. As the commit mentioned this was not a "true" randomisation but a partial one, and only when adding new tasks to the queue, and only "per grouping". The JoinableQueue documentation doesn't mention how items are selected, and if that can be influenced. We could - shooting from the cuff here - subclass this queue so we can add this logic - but that's a much larger change than we want to work on at this time.

@DougBurke
Copy link
Member Author

I'm going to leave this open but mark as a draft.

@DougBurke DougBurke marked this pull request as draft November 19, 2021 16:20
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