{"action":"created","issue":{"url":"https://api.github.com/repos/dask/distributed/issues/264","repository_url":"https://api.github.com/repos/dask/distributed","labels_url":"https://api.github.com/repos/dask/distributed/issues/264/labels{/name}","comments_url":"https://api.github.com/repos/dask/distributed/issues/264/comments","events_url":"https://api.github.com/repos/dask/distributed/issues/264/events","html_url":"https://github.com/dask/distributed/issues/264","id":153438320,"number":264,"title":"CPU affinity of multiple workers on one node","user":{"login":"Kobzol","id":4539057,"avatar_url":"https://avatars.githubusercontent.com/u/4539057?v=3","gravatar_id":"","url":"https://api.github.com/users/Kobzol","html_url":"https://github.com/Kobzol","followers_url":"https://api.github.com/users/Kobzol/followers","following_url":"https://api.github.com/users/Kobzol/following{/other_user}","gists_url":"https://api.github.com/users/Kobzol/gists{/gist_id}","starred_url":"https://api.github.com/users/Kobzol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kobzol/subscriptions","organizations_url":"https://api.github.com/users/Kobzol/orgs","repos_url":"https://api.github.com/users/Kobzol/repos","events_url":"https://api.github.com/users/Kobzol/events{/privacy}","received_events_url":"https://api.github.com/users/Kobzol/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-05-06T12:11:13Z","updated_at":"2016-05-07T07:41:40Z","closed_at":"2016-05-07T07:41:40Z","body":"I'm experiencing a strange behaviour with (broadcast) scatter.\r\nFor development, I launch four workers on my PC (so they share one IP address).\r\nThe PC has 2 CPUs, each with 2 cores (so 4 hyper-threads in total).\r\nBecause the work for each worker cannot benefit from multithreading, I assign just one core to each worker (`ncores=1`).\r\nIf I distribute 4 jobs for them using a simple submit, each worker gets one job - that's fine.\r\nHowever if I use scatter with broadcast and then use the data future from the scatter, the CPU affinity gets weird, just 2 cores are executing the code at once and the whole process is two times longer, so the workers probably aren't all working in parallel.\r\nI'm using the broadcast in this way because of the use case that I described in issue #85.\r\n\r\nHere's a toy MWE:\r\n```python\r\nimport distributed\r\nfrom tornado.ioloop import IOLoop\r\nfrom threading import Thread\r\n\r\nloop = IOLoop()\r\nt = Thread(target=loop.start)\r\nt.daemon = True\r\nt.start()\r\n\r\nscheduler = distributed.Scheduler(ip=\"127.0.0.1\")\r\nscheduler.start(1800)\r\n\r\nworkers = [distributed.Nanny(\"127.0.0.1\", 1800, ncores=1) for i in xrange(4)]\r\nmap(lambda w: w.start(0), workers)\r\n\r\n\r\nclass Test(object):\r\n    def __init__(self, x):\r\n        self.x = x\r\n\r\n\r\ndef fn(test, y):\r\n    result = 1\r\n    for x in xrange(10000):\r\n        for u in xrange(50):\r\n            result *= test.x + y * u\r\n    return result\r\n\r\nexecutor = distributed.Executor(\"127.0.0.1:1800\")\r\ntest = Test(10)\r\n\r\n# Variant A\r\n#[data_future] = executor.scatter([test], broadcast=True)\r\n#tasks = [executor.submit(fn, data_future, i) for i in xrange(4)]\r\n\r\n# Variant B\r\ntasks = [executor.submit(fn, test, i) for i in xrange(4)]\r\n\r\ndata = executor.gather(tasks)\r\n```\r\nVariant A takes two times longer and doesn't execute on all of the cores at once.\r\nI know that this isn't probably a typical usage for distributed, but I don't see why it would behave in this way.\r\nAm I missing something?"},"comment":{"url":"https://api.github.com/repos/dask/distributed/issues/comments/217614011","html_url":"https://github.com/dask/distributed/issues/264#issuecomment-217614011","issue_url":"https://api.github.com/repos/dask/distributed/issues/264","id":217614011,"user":{"login":"Kobzol","id":4539057,"avatar_url":"https://avatars.githubusercontent.com/u/4539057?v=3","gravatar_id":"","url":"https://api.github.com/users/Kobzol","html_url":"https://github.com/Kobzol","followers_url":"https://api.github.com/users/Kobzol/followers","following_url":"https://api.github.com/users/Kobzol/following{/other_user}","gists_url":"https://api.github.com/users/Kobzol/gists{/gist_id}","starred_url":"https://api.github.com/users/Kobzol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kobzol/subscriptions","organizations_url":"https://api.github.com/users/Kobzol/orgs","repos_url":"https://api.github.com/users/Kobzol/repos","events_url":"https://api.github.com/users/Kobzol/events{/privacy}","received_events_url":"https://api.github.com/users/Kobzol/received_events","type":"User","site_admin":false},"created_at":"2016-05-07T07:41:40Z","updated_at":"2016-05-07T07:41:40Z","body":"There were about 10-20 warnings during the execution, but I don't think that it's significant, I didn't notice any problems. I will close this issue for now and if I run into any other affinity issues, I might reopen it in the future."}}