Skip to content

Conversation

@jpsamaroo
Copy link
Member

@jpsamaroo jpsamaroo commented Feb 4, 2020

Allow thunks to dynamically control the scheduler

Todo:

  • exec!
  • add_thunk!
  • get_dag_ids
  • Change API to use task_local_storage for scheduler handle
  • Export dynamic API from Sch
  • Test add_thunk! and wait/fetch! better
  • Update docs for TLS API
  • Expose scheduler control through Context somehow For a future PR
  • Simplify RPC interface to just use exec!
  • Change set_return! to wait/fetch, to allow one thunk to wait on another
  • Use special ThunkID instead of special Arg

@jpsamaroo
Copy link
Member Author

@shashi this is the foundation of what I was discussing with you in Slack today.

Basically, we can expand this code to support modifying the DAG at execution time, with the scheduler support, of course.

@coveralls
Copy link

coveralls commented Feb 4, 2020

Coverage Status

Coverage decreased (-0.4%) to 65.976% when pulling 7658756 on jps/dynamic-thunks into 61ff302 on master.

@jpsamaroo jpsamaroo requested review from shashi and tanmaykm February 4, 2020 23:29
@jpsamaroo
Copy link
Member Author

Bump. Any objections to the idea or implementation?

@jpsamaroo jpsamaroo changed the title Add dynamic thunk mode [WIP] Add dynamic thunk mode and scheduler API Feb 29, 2020
@jpsamaroo
Copy link
Member Author

Thanks for the review! I'll address your recommendations once I come back to this PR, and I also think I'll hold off on merging this until we expose a few more controls through this API, so that we can see what it will ultimately look like. I'd like to at least support adding new thunks to the DAG, and querying the scheduler state and the full DAG structure from this interface.

@jpsamaroo jpsamaroo changed the title [WIP] Add dynamic thunk mode and scheduler API Add dynamic thunk mode and scheduler API May 16, 2020
@jpsamaroo jpsamaroo marked this pull request as draft May 16, 2020 11:41
@jpsamaroo jpsamaroo force-pushed the jps/dynamic-thunks branch from 3cd23c0 to 82f9810 Compare July 25, 2020 20:35
@jpsamaroo
Copy link
Member Author

Note to onlookers: locking was added to allow users to add their own process_dynamic! methods which interact with the scheduler state without stepping on the scheduler's proverbial toes. Finer-grained locking will probably be necessary later on to enable more efficient scheduler modifications. Providing a more fine-grained semi-internal DAG modification API should make concurrent modification much easier and more efficient.

@jpsamaroo jpsamaroo marked this pull request as ready for review July 29, 2020 19:07
@jpsamaroo jpsamaroo marked this pull request as draft October 13, 2020 17:33
@jpsamaroo
Copy link
Member Author

I don't think I'm going to keep the dynamic kwarg; it's ugly and makes the thunk API ugly. We should be able to instead pass the scheduler handle through task_local_storage, which will let us keep thunks working as normal. The only price we pay is getting the scheduler handle each time, which should only be the cost of a dynamic dispatch; this should be insignificant given that most operations on the handle involve network traffic.

@jpsamaroo jpsamaroo force-pushed the jps/dynamic-thunks branch 2 times, most recently from ebdea68 to a79b9e0 Compare November 14, 2020 20:26
@jpsamaroo jpsamaroo changed the title Add dynamic thunk mode and scheduler API Add dynamic scheduler control Nov 14, 2020
@jpsamaroo jpsamaroo force-pushed the jps/dynamic-thunks branch 2 times, most recently from 956ea72 to dd2ec4b Compare November 19, 2020 13:54
@jpsamaroo jpsamaroo marked this pull request as ready for review December 2, 2020 18:47
@jpsamaroo jpsamaroo force-pushed the jps/dynamic-thunks branch 2 times, most recently from 5b2d3a9 to 0213ad3 Compare December 2, 2020 22:19
Add exec! dynamic call to execute arbitrary code in the scheduler
Add halt! function to stop scheduler early
Add get_dag_ids function to query DAG
Add add_thunk! function to add a new thunk to the DAG
Add dynamic wait/fetch of other thunks
Add safepointing to allow safely halting the scheduler
Add locking to the scheduler to allow concurrent state modifications
Fix start_state overwriting state.dependents
Move scheduler into its own folder
Create reschedule_inputs! utility
Change check_exited_exception to unwrap_nested_exception
Remove explicit chan passing in Sch, place it in ComputeState
Add better error reporting to ThreadProc
Set state.thunk_dict during Sch init
@jpsamaroo jpsamaroo merged commit a59f09a into master Dec 2, 2020
@jpsamaroo jpsamaroo deleted the jps/dynamic-thunks branch December 2, 2020 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants