Skip to content

Commit

Permalink
dev: host reconcile jitter
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsingerus committed Nov 22, 2024
1 parent 5246e9c commit 528900a
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pkg/controller/chi/worker-chi-reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (w *worker) reconcileShardsAndHosts(ctx context.Context, shards []*api.ChiS
return nil
}

func (w *worker) runConcurrently(ctx context.Context, workersNum int, startShardIndex int, shards[]*api.ChiShard ) error {
func (w *worker) runConcurrently(ctx context.Context, workersNum int, startShardIndex int, shards []*api.ChiShard) error {
if len(shards) == 0 {
return nil
}
Expand All @@ -527,7 +527,7 @@ func (w *worker) runConcurrently(ctx context.Context, workersNum int, startShard
for i, shard := range shards {
ch <- &shardReconcile{
shard,
startShardIndex+i,
startShardIndex + i,
}
}
}()
Expand Down Expand Up @@ -556,7 +556,7 @@ func (w *worker) runConcurrently(ctx context.Context, workersNum int, startShard
return err
}

func (w *worker) runConcurrentlyInBatches(ctx context.Context, workersNum int, start int, shards[]*api.ChiShard ) error {
func (w *worker) runConcurrentlyInBatches(ctx context.Context, workersNum int, start int, shards []*api.ChiShard) error {
for startShardIndex := 0; startShardIndex < len(shards); startShardIndex += workersNum {
endShardIndex := util.IncTopped(startShardIndex, workersNum, len(shards))
concurrentlyProcessedShards := shards[startShardIndex:endShardIndex]
Expand Down Expand Up @@ -645,6 +645,17 @@ func (w *worker) reconcileHost(ctx context.Context, host *api.Host) error {
w.a.V(2).M(host).S().P()
defer w.a.V(2).M(host).E().P()

//si := host.GetRuntime().GetAddress().GetShardIndex()
//ri := host.GetRuntime().GetAddress().GetReplicaIndex()
////sleep := util.DecBottomed(si, 1, 0)*(si % 3)*20
//sleep := (2 - si)*90
//if ri > 0 {
// sleep = 0
//}
//w.a.V(1).Info("Host [%d/%d]. Going to sleep %d sec", si, ri, sleep)
//time.Sleep((time.Duration)(sleep)*time.Second)
//w.a.V(1).Info("Host [%d/%d]. Done to sleep %d sec", si, ri)

metrics.HostReconcilesStarted(ctx, host.GetCR())
startTime := time.Now()

Expand Down Expand Up @@ -693,16 +704,6 @@ func (w *worker) reconcileHost(ctx context.Context, host *api.Host) error {
metrics.HostReconcilesCompleted(ctx, host.GetCR())
metrics.HostReconcilesTimings(ctx, host.GetCR(), time.Now().Sub(startTime).Seconds())

//si := host.GetRuntime().GetAddress().GetShardIndex()
//ri := host.GetRuntime().GetAddress().GetReplicaIndex()
//sleep := util.DecBottomed(si, 1, 0)*(si % 3)*20
//if ri > 0 {
// sleep = 0
//}
//w.a.V(1).Info("Host [%d/%d]. Going to sleep %d sec", si, ri, sleep)
//time.Sleep((time.Duration)(sleep)*time.Second)
//w.a.V(1).Info("Host [%d/%d]. Done to sleep %d sec", si, ri)

return nil
}

Expand Down

0 comments on commit 528900a

Please sign in to comment.