monitor optimal wait fraction (#2435)

* monitor optimal wait fraction

Change-Id: I1c76da5e8031237cf78ce5a0774732dd5e558ea1

* monitor other times about the upload

Change-Id: Iae81c80fb1446fbf4b3dd04fc6b238f2ede96545
This commit is contained in:
Jeff Wendling 2019-07-02 20:49:35 +00:00 committed by GitHub
parent 9e26149a2d
commit 42e124cd08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,6 +113,8 @@ func (ec *ecClient) Put(ctx context.Context, limits []*pb.AddressedOrderLimit, r
successfulHashes = make([]*pb.PieceHash, len(limits))
var successfulCount int32
var timer *time.Timer
var lastSuccess time.Time
var waitStart time.Time
for range limits {
info := <-infos
@ -131,6 +133,7 @@ func (ec *ecClient) Put(ctx context.Context, limits []*pb.AddressedOrderLimit, r
Address: limits[info.i].GetStorageNodeAddress(),
}
successfulHashes[info.i] = info.hash
lastSuccess = time.Now()
switch int(atomic.AddInt32(&successfulCount, 1)) {
case rs.OptimalThreshold():
@ -140,7 +143,8 @@ func (ec *ecClient) Put(ctx context.Context, limits []*pb.AddressedOrderLimit, r
}
cancel()
case rs.RepairThreshold() + 1:
elapsed := time.Since(start)
waitStart = time.Now()
elapsed := waitStart.Sub(start)
more := elapsed * 3 / 2
ec.log.Sugar().Debugf("Repair threshold (%d nodes) passed in %.2f s. Starting a timer for %.2f s for reaching the success threshold (%d nodes)...",
@ -178,6 +182,17 @@ func (ec *ecClient) Put(ctx context.Context, limits []*pb.AddressedOrderLimit, r
return nil, nil, Error.New("successful puts (%d) less than or equal to repair threshold (%d)", successes, rs.RepairThreshold())
}
// Monitor what the best fraction would have been for this upload.
if !lastSuccess.IsZero() && !waitStart.IsZero() {
repairThreshold := waitStart.Sub(start).Seconds()
extraDuration := lastSuccess.Sub(waitStart).Seconds()
if extraDuration != 0 {
mon.FloatVal("repair_threshold").Observe(repairThreshold)
mon.FloatVal("extra_duration").Observe(extraDuration)
mon.FloatVal("optimal_fraction").Observe(extraDuration / repairThreshold)
}
}
return successfulNodes, successfulHashes, nil
}