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

M:N threading #1198

Merged
merged 12 commits into from Jul 10, 2018
Merged

M:N threading #1198

merged 12 commits into from Jul 10, 2018

Conversation

andrewrk
Copy link
Member

@andrewrk andrewrk commented Jul 5, 2018

  • add std.atomic.QueueMpsc.isEmpty
  • make std.debug.global_allocator thread-safe
  • std.event.Loop: now you have to choose between
    • initSingleThreaded
    • initMultiThreaded
  • std.event.Loop multiplexes coroutines onto kernel threads
  • Remove std.event.Loop.stop. Instead the event loop run() function
    returns once there are no pending coroutines.
  • fix crash in ir.cpp for calling methods under some conditions
  • small progress self-hosted compiler, analyzing top level declarations
  • Introduce std.event.Lock for synchronizing coroutines
  • introduce std.event.Locked(T) for data that only 1 coroutine should
    modify at once.
  • make the self hosted compiler use multi threaded event loop
  • make std.heap.DirectAllocator thread-safe

See #174

TODO:

 * add std.atomic.QueueMpsc.isEmpty
 * make std.debug.global_allocator thread-safe
 * std.event.Loop: now you have to choose between
   - initSingleThreaded
   - initMultiThreaded
 * std.event.Loop multiplexes coroutines onto kernel threads
 * Remove std.event.Loop.stop. Instead the event loop run() function
   returns once there are no pending coroutines.
 * fix crash in ir.cpp for calling methods under some conditions
 * small progress self-hosted compiler, analyzing top level declarations
 * Introduce std.event.Lock for synchronizing coroutines
 * introduce std.event.Locked(T) for data that only 1 coroutine should
   modify at once.
 * make the self hosted compiler use multi threaded event loop
 * make std.heap.DirectAllocator thread-safe

See #174

TODO:
 * call sched_getaffinity instead of hard coding thread pool size 4
 * support for Windows and MacOS
 * #1194
 * #1197
when a thread pool worker accepts a coroutine to resume
@kristate
Copy link
Contributor

kristate commented Jul 7, 2018

Wondering if we need an abstraction for FDs;
On windows we have to work with typedef void * HANDLE

Better to get threading out of the way first before we fine tune event loops, though.

@kristate
Copy link
Contributor

kristate commented Jul 7, 2018

Also, this might be of curiosity to you:
https://blog.marcgravell.com/2018/07/pipe-dreams-part-1.html

@andrewrk
Copy link
Member Author

andrewrk commented Jul 9, 2018

Got it working on MacOS, next up Windows

@andrewrk
Copy link
Member Author

andrewrk commented Jul 9, 2018

@bnoordhuis looks like libuv uses IO Completion Ports. Do you recommend this approach?

@andrewrk
Copy link
Member Author

andrewrk commented Jul 9, 2018

nevermind, it's already done. that was a surprisingly nice API.

@andrewrk andrewrk merged commit ccef60a into master Jul 10, 2018
@andrewrk andrewrk deleted the m-n-threading branch July 10, 2018 02:06
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.

None yet

2 participants