golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.41k stars 17.7k forks source link

runtime: severe performance drop for cgo calls in go1.22.5 [1.23 backport] #69988

Open gopherbot opened 1 month ago

gopherbot commented 1 month ago

@aclements requested issue #68587 to be considered for backport to the next 1.23 minor release.

@gopherbot , please open a backport to 1.23.

aclements commented 1 month ago

This causes a dramatic drop in C -> Go call performance under some circumstances.

Arup-Chauhan commented 1 month ago

Hi @aclements, I wanted to work, this can be a potential workaround.


// Workaround: Use `runtime.LockOSThread()` to minimize thread switching overhead.
// This ensures the goroutine stays on the same OS thread during C -> Go calls.
runtime.LockOSThread()
defer runtime.UnlockOSThread()

Would this be viable? Feedback appreciated.
arl commented 1 month ago

@Arup-Chauhan the problem has already been worked on, the changes should be in next go release and also backported to go1.23. In fact, we're on the backporting issue here. See #68587

Arup-Chauhan commented 1 month ago

Thankyou for the update @arl , I will try to contribute to some other issue then

dmitshur commented 3 weeks ago

We moved the NextMinor label to the parent tracking issue #68587, removing here.