1
2
3
4
5
13
14 package main
15
16 import (
17 "os"
18 "runtime"
19 "runtime/pprof"
20 "sync"
21 "time"
22 )
23
24 func init() {
25 register("Kubernetes58107", Kubernetes58107)
26 }
27
28 type RateLimitingInterface_kubernetes58107 interface {
29 Get()
30 Put()
31 }
32
33 type Type_kubernetes58107 struct {
34 cond *sync.Cond
35 }
36
37 func (q *Type_kubernetes58107) Get() {
38 q.cond.L.Lock()
39 defer q.cond.L.Unlock()
40 q.cond.Wait()
41 }
42
43 func (q *Type_kubernetes58107) Put() {
44 q.cond.Signal()
45 }
46
47 type ResourceQuotaController_kubernetes58107 struct {
48 workerLock sync.RWMutex
49 queue RateLimitingInterface_kubernetes58107
50 missingUsageQueue RateLimitingInterface_kubernetes58107
51 }
52
53 func (rq *ResourceQuotaController_kubernetes58107) worker(queue RateLimitingInterface_kubernetes58107, _ string) {
54 workFunc := func() bool {
55 rq.workerLock.RLock()
56 defer rq.workerLock.RUnlock()
57 queue.Get()
58 return true
59 }
60 for {
61 if quit := workFunc(); quit {
62 return
63 }
64 }
65 }
66
67 func (rq *ResourceQuotaController_kubernetes58107) Run() {
68 go rq.worker(rq.queue, "G1")
69 go rq.worker(rq.missingUsageQueue, "G2")
70 }
71
72 func (rq *ResourceQuotaController_kubernetes58107) Sync() {
73 for i := 0; i < 100000; i++ {
74 rq.workerLock.Lock()
75 runtime.Gosched()
76 rq.workerLock.Unlock()
77 }
78 }
79
80 func (rq *ResourceQuotaController_kubernetes58107) HelperSignals() {
81 for i := 0; i < 100000; i++ {
82 rq.queue.Put()
83 rq.missingUsageQueue.Put()
84 }
85 }
86
87 func startResourceQuotaController_kubernetes58107() {
88 resourceQuotaController := &ResourceQuotaController_kubernetes58107{
89 queue: &Type_kubernetes58107{sync.NewCond(&sync.Mutex{})},
90 missingUsageQueue: &Type_kubernetes58107{sync.NewCond(&sync.Mutex{})},
91 }
92
93 go resourceQuotaController.Run()
94 go resourceQuotaController.Sync()
95 resourceQuotaController.HelperSignals()
96 }
97
98 func Kubernetes58107() {
99 prof := pprof.Lookup("goroutineleak")
100 defer func() {
101 time.Sleep(1000 * time.Millisecond)
102 prof.WriteTo(os.Stdout, 2)
103 }()
104
105 for i := 0; i < 1000; i++ {
106 go startResourceQuotaController_kubernetes58107()
107 }
108 }
109
View as plain text