Skip to content

Make it easier to capture task stream information #2111

Closed

Description

@mrocklin

People often want to get the data on the task stream in a structured format. This is possible today with some pain. Here is an example:

In [1]: from dask.distributed import Client

In [2]: client = Client()

In [3]: # open dashboard to ensure that the scheduler captures information

In [4]: import dask.array as da

In [5]: x = da.random.random((10, 10), chunks=(5, 5))

In [6]: y = (x + x.T).persist()

In [7]: def f(dask_scheduler):
   ...:     from distributed.bokeh.task_stream import TaskStreamPlugin
   ...:     for plugin in dask_scheduler.plugins:
   ...:         if isinstance(plugin, TaskStreamPlugin):
   ...:             return plugin.buffer
   ...:         

In [8]: client.run_on_scheduler(f)
Out[8]: 
[{'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 0, 1)",
  'nbytes': 200,
  'startstops': (('deserialize', 1531409759.1762872, 1531409759.2346888),
   ('compute', 1531409759.2363048, 1531409759.2377546)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41153'},
 {'key': "('transpose-9114dbb1ddcfe7f13e190d36cd1c2016', 1, 0)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.241821, 1531409759.241839),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41153'},
 {'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 0, 0)",
  'nbytes': 200,
  'startstops': (('deserialize', 1531409759.1766217, 1531409759.240885),
   ('compute', 1531409759.241804, 1531409759.2433474)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41901'},
 {'key': "('transpose-add-2a75b9ccf51332e12722bea5cd5fe054', 0, 0)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.247657, 1531409759.2477224),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41901'},
 {'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 0, 0)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.2537527, 1531409759.2537668),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41901'},
 {'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 1, 0)",
  'nbytes': 200,
  'startstops': (('deserialize', 1531409759.1754217, 1531409759.2527452),
   ('compute', 1531409759.2543166, 1531409759.25571)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41139'},
 {'key': "('random_sample-ecda85d77df96a666d2303bc1629d816', 1, 1)",
  'nbytes': 200,
  'startstops': (('deserialize', 1531409759.1780434, 1531409759.2550313),
   ('compute', 1531409759.2560167, 1531409759.2574341)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:46339'},
 {'key': "('transpose-9114dbb1ddcfe7f13e190d36cd1c2016', 0, 1)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.2596776, 1531409759.259698),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41139'},
 {'key': "('transpose-add-2a75b9ccf51332e12722bea5cd5fe054', 1, 1)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.2631009, 1531409759.2631717),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:46339'},
 {'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 1, 1)",
  'nbytes': 200,
  'startstops': (('compute', 1531409759.2695944, 1531409759.269626),),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:46339'},
 {'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 0, 1)",
  'nbytes': 200,
  'startstops': (('transfer', 1531409759.268001, 1531409759.2770529),
   ('compute', 1531409759.2778597, 1531409759.2778904)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41139'},
 {'key': "('add-2a75b9ccf51332e12722bea5cd5fe054', 1, 0)",
  'nbytes': 200,
  'startstops': (('transfer', 1531409759.259737, 1531409759.2771356),
   ('compute', 1531409759.2778504, 1531409759.2778778)),
  'status': 'OK',
  'thread': 140000297481984,
  'type': b'\x80\x04\x95\x15\x00\x00\x00\x00\x00\x00\x00\x8c\x05numpy\x94\x8c\x07ndarray\x94\x93\x94.',
  'worker': 'tcp://127.0.0.1:41153'}]

Some things to clean up:

  1. Make it easier to ensure that the task stream plugin is running without explicitly opening up the dashboard
  2. Make this process idempotent, so that we only ever have one plugin running
  3. Ensure that we want the buffer to be a list, rather than a deque
  4. Make this available through a method on the client

Activity

  1. nicolls1 commented on Jul 16, 2018

    @nicolls1
    Contributor

    Is it possible to specify a plugin on scheduler startup or is this something that could also be included? Does it currently work that the plugin is only run for a given client or when I register a plugin is it for all new and existing connections?

    I am thinking of making a amqp plugin to have the scheduler write the task information for processing externally and I would like to not have to add the plugin every time my clients connect.

    Also for 2, does this mean that the scheduler can not chain plugins together or that when they are multiple they need to be run on the same thread?

  2. mrocklin commented on Jul 16, 2018

    @mrocklin
    MemberAuthor

    Is it possible to specify a plugin on scheduler startup

    The easiest way to do this today would be to add a --preload script. See https://distributed.readthedocs.io/en/latest/setup.html?#customizing-initialization for an example

    I am thinking of making a amqp plugin to have the scheduler write the task information for processing externally and I would like to not have to add the plugin every time my clients connect.

    This would be great to see, especially if it was open sourced somewhere. I think that this would be useful to others as well

    Also for 2, does this mean that the scheduler can not chain plugins together or that when they are multiple they need to be run on the same thread?

    Many plugins operate at the same time. They run in the event loop and so are on the same thread as the scheduler. Ideally their operations should be fast and not block.

  3. nicolls1 commented on Jul 16, 2018

    @nicolls1
    Contributor

    The easiest way to do this today would be to add a --preload script. See https://distributed.readthedocs.io/en/latest/setup.html?#customizing-initialization for an example

    Great thanks! Have been doing this on my workers but didn't realize it could be on the scheduler also. The help string makes it seem like you can only specify what should be run on all workers, maybe I'm on an old version also:

    --preload TEXT          Module that should be loaded by each worker process
                            like "foo.bar" or "/path/to/foo.py"
    

    This would be great to see, especially if it was open sourced somewhere. I think that this would be useful to others as well

    Would an example in the docs be the appropriate way to open source it or what would be the best way in your mind?

    Many plugins operate at the same time. They run in the event loop and so are on the same thread as the scheduler. Ideally their operations should be fast and not block.

    Got it, thanks!

  4. mrocklin commented on Jul 16, 2018

    @mrocklin
    MemberAuthor

    Ah, indeed. Do you have any desire to fix the help string there?

  5. nicolls1 commented on Jul 16, 2018

    @nicolls1
    Contributor

    Sure, will do.

  6. mrocklin commented on Jul 16, 2018

    @mrocklin
    MemberAuthor

    Would an example in the docs be the appropriate way to open source it or what would be the best way in your mind?

    That might be best. I'm not sure. I'm a little curious how large it will be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions