Questions tagged [go-scheduler]

4 questions
3
votes
1 answer

Observing average wait time for goroutines

I'm running a server application serving a high number of QPS and for each query I perform some computation which is heavily CPU bounded. I took a trace and put a screenshot below. The x-axis is the time and the y axis is the number of…
jeremie
  • 971
  • 9
  • 19
2
votes
2 answers

Why isn't this goroutine run, even with a `time.Sleep`?

Take this piece of code: func main() { var x int go func() { for { x++ } }() time.Sleep(time.Second) fmt.Println("x =", x) } Why does x equal 0 at the end? I understand that Go's scheduler needs the…
2hamed
  • 8,719
  • 13
  • 69
  • 112
-1
votes
1 answer

Ask Go to run all goroutines before continuing

I need that the Golang scheduler run all goroutines before continue, runtime.Gosched() does not solve. The problem is that the go routine can run so fast that the "select" in start() run after the "select" inside de stopStream(), then the "case…
-1
votes
2 answers

go buffered channel (capacity 4) accepts 5 without blocking

I have the go code, that basically runs two go routines concurrently. One of them sends 10 int numbers from (1-10) to the buffered channel "ch"(capacity is 4), and another go routine reads values from channel with the help of for range loop …
Genjik
  • 320
  • 1
  • 7
  • 20