Asynchronous preemption

474 views
Skip to first unread message

Yonatan Gizachew

unread,
Sep 2, 2020, 10:14:58 PM9/2/20
to golang-nuts
Is it possible to stop the asynchronous preemption like:
GODEBUG=asyncpreemptoff=1 go build -o libgotest.so -buildmode=c-shared -compiler=gccgo test.go

I am using gccgo compiler. 

Kurtis Rader

unread,
Sep 2, 2020, 10:29:31 PM9/2/20
to Yonatan Gizachew, golang-nuts
Yes, although that will only disable async preemption for the "go build" tool chain. It will not disable it in the binary that is the result. So, no, it won't do what I think you're requesting. The reason this is controlled via the "GODEBUG" env var is because it is meant for debugging. It is not expected that a Go program will need to disable async preemption 100% of the time. If you have a situation that does need to always disable it you should probably open a bug report.

--
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

Ian Lance Taylor

unread,
Sep 2, 2020, 11:35:26 PM9/2/20
to Yonatan Gizachew, golang-nuts
On Wed, Sep 2, 2020 at 7:14 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>
Note that executables built by the gccgo compiler don't use
asynchronous preemption.

Ian

Yonatan Gizachew

unread,
Sep 2, 2020, 11:38:03 PM9/2/20
to Kurtis Rader, golang-nuts
Ok, thanks for the clarification. 

Yonatan Gizachew

unread,
Sep 3, 2020, 12:12:00 AM9/3/20
to golang-nuts
I see. If that is so, what is the job of sysmon thread?

Ian Lance Taylor

unread,
Sep 4, 2020, 11:01:03 PM9/4/20
to Yonatan Gizachew, golang-nuts
On Wed, Sep 2, 2020 at 9:11 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>
> I see. If that is so, what is the job of sysmon thread?

The sysmon thread is not related to asynchronous preemption. The
sysmon thread does a few different things. One of the things it does
is notice threads that have been stuck in a system call for a while,
and detach them from their P, and start running a new thread
associated with that P. This is scheduler activity, and it permits
additional parallelism in the program, but it's not preemption.

Ian

> On Thursday, September 3, 2020 at 12:35:26 PM UTC+9 Ian Lance Taylor wrote:
>>
>> On Wed, Sep 2, 2020 at 7:14 PM Yonatan Gizachew <eme...@gmail.com> wrote:
>> >
>> > Is it possible to stop the asynchronous preemption like:
>> > GODEBUG=asyncpreemptoff=1 go build -o libgotest.so -buildmode=c-shared -compiler=gccgo test.go
>> >
>> > I am using gccgo compiler.
>>
>> Note that executables built by the gccgo compiler don't use
>> asynchronous preemption.
>>
>> Ian
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2b865dc9-7992-4239-9d5f-09c0ba1fa369n%40googlegroups.com.

Yonatan Gizachew

unread,
Sep 7, 2020, 10:02:00 PM9/7/20
to golang-nuts
Got it. Thank you!
Reply all
Reply to author
Forward
0 new messages