On Mon, Apr 27, 2015 at 1:55 PM, Shawn Landden <
shawnl...@gmail.com> wrote:
>
> On Monday, April 27, 2015 at 6:20:21 AM UTC-7, Dave Cheney wrote:
>>
>> Possibly, that is how the JVM does it, but the stack check prolog is also
>> used for preemption (sort of like a safe point), and in general usage the
>> stack check is predictable by the cpu, so effectively free.
>
> Considering that we always schedule on a potentially blocking operation do
> we really need this level of preemption?
It measurably reduces the length of time that the GC has to wait for
all threads to acknowledge a phase change. This is because it is no
longer necessary to wait for the goroutine to make a potentially
blocking operation, it is only necessary to wait for the goroutine to
make a function call. Even that is not perfect, of course, and there
has been discussion off and on of checking for preemption in backward
branches in possibly long-running or infinite loops.
Ian