The potential guarantee from the memory model guarantees is that an A
happens before the corresponding B (because limit is buffered), so if
the memory model determines execution order here we can't formally say
that limit does stop concFunc1 from executing concurrently more than
cap(limit) times.
Is the memory model important here? If it's not, what is?
Dan
[1]https://codereview.appspot.com/13038043/
[2]https://groups.google.com/d/topic/golang-nuts/Ug1DhZGGqTk
[3]https://groups.google.com/d/topic/golang-dev/ShqsqvCzkWg
[4]https://groups.google.com/d/msg/golang-dev/ShqsqvCzkWg/9WGj2yPK9xYJ
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
On Mon, Aug 19, 2013 at 3:40 AM, Dmitry Vyukov <dvy...@google.com> wrote:We know that gccgo/llvmgo are not going to rearrange program execution
> I need to admit that this is mostly theoretical.
> One practical implication is complains from race detector, however, it won't
> complain on most cases.
> I can imagine that gccgo/llvmgo can actually break such code in distant
> future provided that it does whole program analysis and agressive
> optimizations. Because they will move in that direction for C/C++.
around channel operations, because that would be baffling.
The
question is more one of how to adjust the memory model, or possibly
the language spec, to make clear that any such rearrangement is
invalid.
On Mon, Aug 19, 2013 at 5:26 PM, Dmitry Vyukov <dvy...@google.com> wrote:
On Tue, Aug 20, 2013 at 4:15 AM, Ian Lance Taylor <ia...@golang.org> wrote:
On Mon, Aug 19, 2013 at 3:40 AM, Dmitry Vyukov <dvy...@google.com> wrote:We know that gccgo/llvmgo are not going to rearrange program execution
> I need to admit that this is mostly theoretical.
> One practical implication is complains from race detector, however, it won't
> complain on most cases.
> I can imagine that gccgo/llvmgo can actually break such code in distant
> future provided that it does whole program analysis and agressive
> optimizations. Because they will move in that direction for C/C++.
around channel operations, because that would be baffling.Do you mean that it will be baffling, because we have lots of invalid programs out there :)The
question is more one of how to adjust the memory model, or possibly
the language spec, to make clear that any such rearrangement is
invalid.N-th receive happens-before N+cap(c) send.This is actually a generalization of the special rule for sync channels. If cap==0, then N-th recv happens-before N-th receive. So that special rule can be removed.Will this make the "incorrect" semaphore suddenly correct?
On 20/08/13 01:26, Dmitry Vyukov wrote:In the past there were objections to adding this rule to the memory model. If I remember correctly:
N-th receive happens-before N+cap(c) send.
- one objection was that it would prevent the compiler from applying some optimisations (are there any of such optimisations currently in use?)
- it would synchronise a send and a receive that are, in principle, unrelated (one could use the implementation of a work group using buffered channels as a counter-example)
On 20/08/13 12:15, Dmitry Vyukov wrote:
Why is it bad?
I don't think it's bad.
What exactly do you mean by work group counter-example?
Are there any other reason not to extend the memory model in this way?
What I mean is that the objection the Nth receive and the (N+cap)th send are unrelated events is not valid when one tries to implement a work group using Dan's concFunc1()[1].
[1] https://groups.google.com/d/msg/golang-nuts/wSRqJLvVTzo/uDl0dmgu208J
I've just found the original thread:
https://groups.google.com/d/msg/golang-nuts/MDvnk1Ax7UQ/eQGkJJmOxc4J
One of the objections raised against rule 4 (that I think it's equivalent to "the Nth receive and the (N+cap)th send" rule) is given by Gustavo:
https://groups.google.com/d/msg/golang-nuts/MDvnk1Ax7UQ/kXtjcFpSd0UJ
Personally, I have no objections. I want to understand the pros and cons.
From your previous response, I understand that adding this rule has negligible effect on performance.
With my email, I was trying to prompt other people to raise any other concerns. If there aren't any other concerns, I think Go would benefit from adding such a rule.
On Tue, Aug 20, 2013 at 4:50 AM, Kyle Lemons <kev...@google.com> wrote:
On Mon, Aug 19, 2013 at 5:26 PM, Dmitry Vyukov <dvy...@google.com> wrote:
On Tue, Aug 20, 2013 at 4:15 AM, Ian Lance Taylor <ia...@golang.org> wrote:
On Mon, Aug 19, 2013 at 3:40 AM, Dmitry Vyukov <dvy...@google.com> wrote:We know that gccgo/llvmgo are not going to rearrange program execution
> I need to admit that this is mostly theoretical.
> One practical implication is complains from race detector, however, it won't
> complain on most cases.
> I can imagine that gccgo/llvmgo can actually break such code in distant
> future provided that it does whole program analysis and agressive
> optimizations. Because they will move in that direction for C/C++.
around channel operations, because that would be baffling.Do you mean that it will be baffling, because we have lots of invalid programs out there :)The
question is more one of how to adjust the memory model, or possibly
the language spec, to make clear that any such rearrangement is
invalid.N-th receive happens-before N+cap(c) send.This is actually a generalization of the special rule for sync channels. If cap==0, then N-th recv happens-before N-th receive. So that special rule can be removed.Will this make the "incorrect" semaphore suddenly correct?Yes, it is.