Skip to content

Commit

Permalink
feat: increase buffer size
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Jan 27, 2025
1 parent 800f865 commit e0e3918
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go/vt/discovery/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ func (hc *HealthCheckImpl) recomputeHealthy(key KeyspaceShardTabletType) {
func (hc *HealthCheckImpl) Subscribe() chan *TabletHealth {
hc.subMu.Lock()
defer hc.subMu.Unlock()
c := make(chan *TabletHealth, 2)
c := make(chan *TabletHealth, 1024)
hc.subscribers[c] = struct{}{}
return c
}
Expand Down
10 changes: 5 additions & 5 deletions go/vt/discovery/healthcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/test/utils"
"vitess.io/vitess/go/vt/concurrency"
"vitess.io/vitess/go/vt/grpcclient"
"vitess.io/vitess/go/vt/topo"
"vitess.io/vitess/go/vt/topo/memorytopo"
Expand Down Expand Up @@ -1509,6 +1508,7 @@ func TestConcurrentUpdates(t *testing.T) {
// Unsubscribe from the healthcheck
// and verify we process all the updates eventually.
hc.Unsubscribe(ch)
defer close(ch)
require.Eventuallyf(t, func() bool {
return totalUpdates == totalCount
}, 5*time.Second, 100*time.Millisecond, "expected all updates to be processed")
Expand Down Expand Up @@ -1537,7 +1537,7 @@ func BenchmarkAccess_FastConsumer(b *testing.B) {
hc.broadcast(&TabletHealth{})
}
hc.Unsubscribe(ch)
waitForEmptyMessageQueue(hc.subscribers[ch])
waitForEmptyMessageQueue(ch)
}
}

Expand Down Expand Up @@ -1565,13 +1565,13 @@ func BenchmarkAccess_SlowConsumer(b *testing.B) {
hc.broadcast(&TabletHealth{})
}
hc.Unsubscribe(ch)
waitForEmptyMessageQueue(hc.subscribers[ch])
waitForEmptyMessageQueue(ch)
}
}

func waitForEmptyMessageQueue(queue *concurrency.MessageQueue[*TabletHealth]) {
func waitForEmptyMessageQueue(queue chan *TabletHealth) {
for {
if queue.Length() == 0 {
if len(queue) == 0 {
return
}
time.Sleep(100 * time.Millisecond)
Expand Down

0 comments on commit e0e3918

Please sign in to comment.