unsafe cgo calls

127 views
Skip to first unread message

Anand Aiyer

unread,
Jun 29, 2022, 12:55:57 AM6/29/22
to golang-dev
cgo calls have an overhead as the scheduler has to be informed of the change of behavior of the go routine, in order to handle situations where the C call might block for a long time.

Would have an "unsafe" cgo call convention that would bypass informing the scheduler? This would allow faster calls into C code, where the developer would be sure that it won't block for long or such a block is acceptable for their use case?

Thoughts?

Ian Lance Taylor

unread,
Jun 29, 2022, 1:26:41 AM6/29/22
to Anand Aiyer, golang-dev
A similar idea was discussed at https://go.dev/issue/42469.

The main cost is that if you make a mistake the program will hang
unpredictably. That is a pretty big cost, and so far we aren't
willing to pay it.

Ian
Reply all
Reply to author
Forward
0 new messages