{"action":"created","issue":{"url":"https://api.github.com/repos/dabeaz/curio/issues/270","repository_url":"https://api.github.com/repos/dabeaz/curio","labels_url":"https://api.github.com/repos/dabeaz/curio/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/dabeaz/curio/issues/270/comments","events_url":"https://api.github.com/repos/dabeaz/curio/issues/270/events","html_url":"https://github.com/dabeaz/curio/issues/270","id":340117948,"node_id":"MDU6SXNzdWUzNDAxMTc5NDg=","number":270,"title":"performance problem --- a delay when task come to the curio.run func","user":{"login":"JmSeason","id":11632481,"node_id":"MDQ6VXNlcjExNjMyNDgx","avatar_url":"https://avatars2.githubusercontent.com/u/11632481?v=4","gravatar_id":"","url":"https://api.github.com/users/JmSeason","html_url":"https://github.com/JmSeason","followers_url":"https://api.github.com/users/JmSeason/followers","following_url":"https://api.github.com/users/JmSeason/following{/other_user}","gists_url":"https://api.github.com/users/JmSeason/gists{/gist_id}","starred_url":"https://api.github.com/users/JmSeason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JmSeason/subscriptions","organizations_url":"https://api.github.com/users/JmSeason/orgs","repos_url":"https://api.github.com/users/JmSeason/repos","events_url":"https://api.github.com/users/JmSeason/events{/privacy}","received_events_url":"https://api.github.com/users/JmSeason/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-07-11T07:09:15Z","updated_at":"2018-07-13T11:21:39Z","closed_at":null,"author_association":"NONE","body":"here is my code:\r\n---------------------------------------------\r\n```\r\nfrom curio import *\r\nimport time\r\nfrom curio.debug import traptrace, schedtrace\r\nimport logging\r\n\r\nlogging.basicConfig(level=logging.DEBUG)\r\n\r\nasync def task1():\r\n    while True:\r\n        await sleep(0)\r\n    \r\nasync def task2():\r\n    while True:\r\n        await sleep(0)\r\n\r\nasync def run_tasks():\r\n    async with TaskGroup(wait=any) as g:\r\n        t1 = await g.spawn(task1)\r\n        t2 = await g.spawn(task2)\r\n        \r\nasync def main():\r\n    task = await spawn(run_tasks)\r\n    while True:\r\n        await sleep(0)\r\n    await task.join()\r\n    \r\nrun(main, debug=traptrace)\r\n```\r\n------------------------------------------------------\r\n\r\nwhen i run this, i got console output below:\r\n---------------------------------------------------\r\nINFO:curio.debug:TRAP:1531291958.432000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.432000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.433000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.448000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.448000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.449000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.464000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.464000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.465000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.479000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.479000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.479000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.495000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.495000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.495000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.510000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.510000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.510000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.526000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.526000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.527000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.542000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.542000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.543000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.557000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.557000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.557000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.573000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.573000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.573000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.588000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.588000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.588000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.604000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.604000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.605000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.620000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.620000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.620000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.635000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.635000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.635000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.651000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.651000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.651000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.666000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.666000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.666000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.682000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.682000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.683000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.698000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.698000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.698000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.713000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.713000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.713000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.729000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.729000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.729000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.744000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.744000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.744000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.760000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.760000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.760000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.776000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.776000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.776000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.791000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.791000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.792000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.807000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.807000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.807000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.822000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.822000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.822000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.838000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.838000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.838000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.854000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.854000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.854000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.869000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.869000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.870000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.885000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.885000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.885000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.900000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.900000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.900000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.916000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.916000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.916000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.932000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.932000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.933000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.947000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.947000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.947000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.963000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.963000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.963000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.978000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.978000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.979000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.994000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.994000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291958.994000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.010000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.010000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.010000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.025000:Task(id=2, name='main'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.025000:Task(id=4, name='task1'):Traps._trap_sleep:(0, False)\r\nINFO:curio.debug:TRAP:1531291959.025000:Task(id=5, name='task2'):Traps._trap_sleep:(0, False)\r\n.........\r\n--------------------------------------------------\r\n\r\nmy question is that why task turn to the 'main' task it would delay about 0.015 seconds, but my main or task1, task2 did nothing(just sleep)"},"comment":{"url":"https://api.github.com/repos/dabeaz/curio/issues/comments/404805051","html_url":"https://github.com/dabeaz/curio/issues/270#issuecomment-404805051","issue_url":"https://api.github.com/repos/dabeaz/curio/issues/270","id":404805051,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDgwNTA1MQ==","user":{"login":"dabeaz","id":350836,"node_id":"MDQ6VXNlcjM1MDgzNg==","avatar_url":"https://avatars2.githubusercontent.com/u/350836?v=4","gravatar_id":"","url":"https://api.github.com/users/dabeaz","html_url":"https://github.com/dabeaz","followers_url":"https://api.github.com/users/dabeaz/followers","following_url":"https://api.github.com/users/dabeaz/following{/other_user}","gists_url":"https://api.github.com/users/dabeaz/gists{/gist_id}","starred_url":"https://api.github.com/users/dabeaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabeaz/subscriptions","organizations_url":"https://api.github.com/users/dabeaz/orgs","repos_url":"https://api.github.com/users/dabeaz/repos","events_url":"https://api.github.com/users/dabeaz/events{/privacy}","received_events_url":"https://api.github.com/users/dabeaz/received_events","type":"User","site_admin":false},"created_at":"2018-07-13T11:21:39Z","updated_at":"2018-07-13T11:21:39Z","author_association":"OWNER","body":"There's really not much for me to work with on this bug report because the supplied code and described application is so vague.   Curio is not large.  The main kernel loop is not doing much.   The only thing that comes to mind is perhaps some kind of Windows-specific thing related to I/O polling.  Curio uses the Python default selector for I/O polling which is based (AFAIK) on select().  Maybe there's some kind of performance issue with that.\r\n\r\nAlternatively, perhaps Trio is making an optimization to not poll for I/O if it knows that know tasks are actually waiting for any I/O.   "}}
{"actor":{"display_login":"dabeaz"}}