Can we play with Go scheduler?

Hi Gophers,

I am working on verifying Go applications and wondering if you are aware of any way to manipulate the scheduler? I only found runtime.Gosched() that preempt the thread (M) from the current goroutine and give back the control to the scheduler to execute a runnable goroutine from the queue. But for the sake of systematic search-space reduction for dynamic verification, I need a way to dictate interleavings of goroutines (e.g., what goroutine to execute after a context switch).
I would appreciate any input on this topic.

Thanks,
Saeed

Go is an open source project. You can clone the sources, modify the runtime scheduler, build them on your own machine, and run them.

Installing Go from source

Thanks petrus for replying to this.

You are right and thanks to Go’s open-source, yes we can do that. I was wondering if there is something else out there that I am not aware of!

I think that is all you will get unless you play with unsafe or hack on the Go source. There are deliberately few tuning parameters in the runtime to give the Go team the freedom to change how it works.

1 Like

True.
Dmitry Vyukov (and others) designed wrote the amazing scheduler (and the whole runtime) with a lot of creativity to make it efficient and safe. I am reading the source to find code regions that are responsible for picking a G from the available (aka “runnable”) G queue. Then I can change the scheduler algorithm and pick random goroutines to execute.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.