Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upsolve concurrency #174
Comments
andrewrk
added
the
enhancement
label
Aug 25, 2016
andrewrk
added this to the 0.1.0 milestone
Aug 25, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
winksaville
Sep 3, 2016
Contributor
Are you able to use Atomic code generation natively in Zig? If not that would be a great place to start.
|
Are you able to use Atomic code generation natively in Zig? If not that would be a great place to start. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Sep 3, 2016
Member
We have some built-in functions for this currently with plans to for many more atomic primitives.
In addition this issue is calling to research M:N threading and perhaps some kind of promise abstraction and/or cooperative multithreading.
|
We have some built-in functions for this currently with plans to for many more atomic primitives. In addition this issue is calling to research M:N threading and perhaps some kind of promise abstraction and/or cooperative multithreading. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
winksaville
Sep 5, 2016
Contributor
Nice to hear atomics are supported. I'd like to caution on keeping things simple, one thing I really like about C is that I have very good control on how big programs are. You can create programs which don't use any "std" libraries and create code that are just a few bytes in size. Another words the programmer is in complete control.
So I suggest, if you want to have features like M:N threading or whatever, there should be no cost in speed or size in programs that don't use them.
|
Nice to hear atomics are supported. I'd like to caution on keeping things simple, one thing I really like about C is that I have very good control on how big programs are. You can create programs which don't use any "std" libraries and create code that are just a few bytes in size. Another words the programmer is in complete control. So I suggest, if you want to have features like M:N threading or whatever, there should be no cost in speed or size in programs that don't use them. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Sep 5, 2016
Member
Your comments are in complete alignment with Zig's philosophy. Whatever concurrency features we have, they will be built on top of the kernel thread abstraction that will be provided in the standard library, and they will not depend on a black box runtime or hide errors such as memory allocation failure.
|
Your comments are in complete alignment with Zig's philosophy. Whatever concurrency features we have, they will be built on top of the kernel thread abstraction that will be provided in the standard library, and they will not depend on a black box runtime or hide errors such as memory allocation failure. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
aindigo
Sep 22, 2016
Contributor
Just my opinion: i think LibUV has an excellent and industry proven abstraction for tasks and sockets/filesystem IO, and sits just in the middle of ASIO/STDC++ and threads in C11, I'm familiarising with zig trying to port parts of the async loop of that library using BSD's kqueue, but first I have to finish an allocator using mmap.
|
Just my opinion: i think LibUV has an excellent and industry proven abstraction for tasks and sockets/filesystem IO, and sits just in the middle of ASIO/STDC++ and threads in C11, I'm familiarising with zig trying to port parts of the async loop of that library using BSD's kqueue, but first I have to finish an allocator using mmap. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Sep 22, 2016
Member
but first I have to finish an allocator using mmap.
ahh, very exciting. How do you plan to handle the problem of different threads allocating and deallocating memory?
ahh, very exciting. How do you plan to handle the problem of different threads allocating and deallocating memory? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
aindigo
Sep 22, 2016
Contributor
Im currently reading the malloc related source code in http://opensource.apple.com//source/Libc/Libc-583/gen/malloc.c it seems that it take pages with mmap, the expensive syscall ( it seems mmap is thread safe) is done less frequently and in the actual malloc call that subdivides the page for allocations just lock a mutex releasing it when it finish (macros MALLOC_LOCK and MALLOC_UNLOCK) , note : osx deprecated the use of sbrk and brk.
edit: good reading on the subject : Mac OS X Internals: A Systems Approach (memory chapter)
|
Im currently reading the malloc related source code in http://opensource.apple.com//source/Libc/Libc-583/gen/malloc.c it seems that it take pages with mmap, the expensive syscall ( it seems mmap is thread safe) is done less frequently and in the actual malloc call that subdivides the page for allocations just lock a mutex releasing it when it finish (macros MALLOC_LOCK and MALLOC_UNLOCK) , note : osx deprecated the use of sbrk and brk. edit: good reading on the subject : Mac OS X Internals: A Systems Approach (memory chapter) |
andrewrk
modified the milestones:
0.1.0,
0.2.0
Apr 20, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kyle-github
Sep 15, 2017
Very belated comment.
I strongly suggest not supporting M:N threading.
TL;DR: nearly every system that did use it in the past has abandoned it including Java, Solaris, Linux...
Some light reading. Dan Kegel has some good links in his C10k web pages:
There was an interesting discussion on the Rust lists a few years ago about this (a bit of a slog to read):
kyle-github
commented
Sep 15, 2017
|
Very belated comment. I strongly suggest not supporting M:N threading. TL;DR: nearly every system that did use it in the past has abandoned it including Java, Solaris, Linux... Some light reading. Dan Kegel has some good links in his C10k web pages: There was an interesting discussion on the Rust lists a few years ago about this (a bit of a slog to read): |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kyle-github
Sep 15, 2017
In view of systems selling now with 32+ cores on the desktop, it seems like the benefits of M:N threading are less and less obvious. At the same time, there seems to have been little progress made on the problems with it.
kyle-github
commented
Sep 15, 2017
|
In view of systems selling now with 32+ cores on the desktop, it seems like the benefits of M:N threading are less and less obvious. At the same time, there seems to have been little progress made on the problems with it. |
referenced
this issue
Oct 9, 2017
andrewrk
referenced this issue
Oct 15, 2017
Open
remove workaround on windows which disables byval parameters #536
andrewrk
modified the milestones:
0.2.0,
0.3.0
Jan 6, 2018
andrewrk
referenced this issue
Jan 29, 2018
Closed
Coroutines (async/await/promise) language support #727
andrewrk
modified the milestones:
0.3.0,
0.4.0
Feb 28, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Mar 3, 2018
Member
We're one step closer to having solved concurrency now that we have coroutines.
Next steps:
- Kernel threads in the standard library. Thread local variables?
- Proof of concept M:N threading. (multiplex coroutines onto a thread pool)
- Static call graph analysis to determine worst case stack upper bound.
After this, concurrency will be solved.
|
We're one step closer to having solved concurrency now that we have coroutines. Next steps:
After this, concurrency will be solved. |
added a commit
that referenced
this issue
Apr 14, 2018
added a commit
that referenced
this issue
Apr 15, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
binary132
May 5, 2018
I hope you don't substitute a serial event loop and callbacks for concurrency. I think the Rust experimental RFC for adding yield / generator-style coroutines is a pretty good read. Here it is: https://github.com/rust-lang/rfcs/blob/master/text/2033-experimental-coroutines.md
binary132
commented
May 5, 2018
•
|
I hope you don't substitute a serial event loop and callbacks for concurrency. I think the Rust experimental RFC for adding yield / generator-style coroutines is a pretty good read. Here it is: https://github.com/rust-lang/rfcs/blob/master/text/2033-experimental-coroutines.md |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pjz
Jun 11, 2018
Someone else's recent thoughts on concurrency are at https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ ; I tend to agree philosophically, though I think in Zig the right answer might be handing in Nurseries much like Allocators.
pjz
commented
Jun 11, 2018
|
Someone else's recent thoughts on concurrency are at https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ ; I tend to agree philosophically, though I think in Zig the right answer might be handing in Nurseries much like Allocators. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
binary132
Jun 11, 2018
go is nice because it's an extremely simple API.
I think go is not aligned with Zig design principles (it hides complexity and runtime cost, and lacks a sane error-handling or panic/unwind approach) and neither is a "concurrency framework" (framework is a dirty word for similar reasons.) I think a Zig-aligned solution is to offer a small and simple set of orthogonal APIs that users can build abstractions on, such as go or spawn, in a safe and zero-cost way, if they would like to.
Here is another good article on problems intrinsic to "concurrency" where the goroutine model falls short:
NUMA-aware scheduler for Go (and HN discussion)
binary132
commented
Jun 11, 2018
•
|
I think Here is another good article on problems intrinsic to "concurrency" where the goroutine model falls short: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
pjz
Jun 13, 2018
The point of that article is that error handling in the context of concurrency can be difficult using traditional primitives, and wrapping them up in something like a Nursery (see the paper) helps by having a concurrency manager (much like an Allocator is an 'allocation manager') to deal with catching/handling errors and... managing concurrency.
pjz
commented
Jun 13, 2018
|
The point of that article is that error handling in the context of concurrency can be difficult using traditional primitives, and wrapping them up in something like a Nursery (see the paper) helps by having a concurrency manager (much like an Allocator is an 'allocation manager') to deal with catching/handling errors and... managing concurrency. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
isaachier
Jun 13, 2018
Contributor
I think people misunderstand the mission of Zig. The idea of "perfect software" is not to say that Zig wants to make errors impossible (which seems to be more of a Rust goal). What it means is that only Zig and C enable local handling of out of memory errors. C++, Rust, Java, Go, Python, Ruby, etc. all handle OOM through exceptions (or crashing), which leads to unsafe code that isn't handled at the call site. No one writes C++ with every std::vector::push wrapped in a try/catch to check for OOM. Zig is a modern flavor of the C approach without some of C's undefined behavior.
TL;DR IMO Zig is not in the business of forbidding unsafe practices. In fact, Zig should encourage low-level, unsafe code and keep opinions to itself. Zig's only axiom is that error values are better than exceptions. I think the ideas put forward here are interesting and might be worth putting in an external library, but not fundamental to the language in any way.
|
I think people misunderstand the mission of Zig. The idea of "perfect software" is not to say that Zig wants to make errors impossible (which seems to be more of a Rust goal). What it means is that only Zig and C enable local handling of out of memory errors. C++, Rust, Java, Go, Python, Ruby, etc. all handle OOM through exceptions (or crashing), which leads to unsafe code that isn't handled at the call site. No one writes C++ with every TL;DR IMO Zig is not in the business of forbidding unsafe practices. In fact, Zig should encourage low-level, unsafe code and keep opinions to itself. Zig's only axiom is that error values are better than exceptions. I think the ideas put forward here are interesting and might be worth putting in an external library, but not fundamental to the language in any way. |
added a commit
that referenced
this issue
Jul 5, 2018
added a commit
that referenced
this issue
Jul 7, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Jul 11, 2018
Member
Concurrency is solved. We have the ability to create kernel threads on all supported targets using std.os.spawnThread. On top of that we have M:N threading implemented in userland with coroutines using async/await syntax. For example:
std.event.Loopstd.event.Lockstd.event.Channelstd.event.Groupstd.event.Future
The self-hosted compiler is underway using these abstractions.
The @atomicRmw issue mentioned above is a separate issue: #1220
Also stack upper bound determination is a separate issue: #157
|
Concurrency is solved. We have the ability to create kernel threads on all supported targets using
The self-hosted compiler is underway using these abstractions. The |
andrewrk
closed this
Jul 11, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
monouser7dig
Jul 11, 2018
I would like to suggest that issues should only be marked as done once documentation is added because without documentation any feature is about as good as if it would not exist in the fist place.
Maybe this is too much to ask at this point but nevertheless wanted to express this opinion because at this point (seeing the issue is closed) I would love to read into some nice examples.
Thanks for your work
monouser7dig
commented
Jul 11, 2018
|
I would like to suggest that issues should only be marked as done once documentation is added because without documentation any feature is about as good as if it would not exist in the fist place. Maybe this is too much to ask at this point but nevertheless wanted to express this opinion because at this point (seeing the issue is closed) I would love to read into some nice examples. Thanks for your work |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
andrewrk
Jul 11, 2018
Member
I agree with you about how important docs are. Here are my priorities:
- stabilize the language
- document everything about the language
- stabilize the standard library
- document everything about the standard library
- 1.0.0
So far we're still on (1).
|
I agree with you about how important docs are. Here are my priorities:
So far we're still on (1). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
monouser7dig
commented
Jul 11, 2018
|
ok I was just too eager to read on, but I'll wait, no problem |
andrewrk commentedAug 25, 2016
•
edited
Edited 11 times
-
andrewrk
edited Jul 11, 2018 (most recent)
-
andrewrk
edited Jul 11, 2018
-
andrewrk
edited Jul 11, 2018
-
andrewrk
edited Jul 11, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
-
andrewrk
edited Apr 16, 2018
On top of the ability to create a kernel thread, Zig should have an abstraction that allows code to express concurrency.
async/await)booland integers with bit counts not powers of 2. for atomicrmw as well as atomicload. #1220