github.com/anycable/anycable-go@v1.5.1/features/goroutines.benchfile (about)

     1  launch :rpc, "bundle exec anyt --only-rpc"
     2  wait_tcp 50051
     3  
     4  launch :anycable, "./dist/anycable-go"
     5  wait_tcp 8080
     6  
     7  BENCHMARK_COMMAND = <<~CMD
     8    websocket-bench broadcast --concurrent 10 --sample-size 100 \
     9    --step-size 200 --payload-padding 200 --total-steps 3 \
    10    ws://localhost:8080/cable --server-type=actioncable
    11  CMD
    12  
    13  IDLE_ROUTINES_MAX = 200
    14  
    15  results = 2.times.map do |i|
    16    run :bench, BENCHMARK_COMMAND
    17    # Give some time to cool down after the benchmark
    18    sleep 5
    19  
    20    gops(pid(:anycable))["goroutines"].tap do |num|
    21      fail "Failed to gops process: #{pid(:anycable)}" unless num
    22  
    23      if num > IDLE_ROUTINES_MAX
    24        fail "Too many goroutines: #{num}"
    25      end
    26    end
    27  end
    28  
    29  if (results[1] / results[0].to_f) > 1.1
    30    fail "Go routines leak detected: #{results[0]} -> #{results[1]}"
    31  end