]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / google.golang.org / grpc / internal / transport / bdp_estimator.go
similarity index 86%
rename from vendor/google.golang.org/grpc/transport/bdp_estimator.go
rename to vendor/google.golang.org/grpc/internal/transport/bdp_estimator.go
index 667edb80b20815045568d33d771176e0de1b6f56..070680edbac1271bda40a5cb99bc61789fef7887 100644 (file)
@@ -24,9 +24,10 @@ import (
 )
 
 const (
-       // bdpLimit is the maximum value the flow control windows
-       // will be increased to.
-       bdpLimit = (1 << 20) * 4
+       // bdpLimit is the maximum value the flow control windows will be increased
+       // to.  TCP typically limits this to 4MB, but some systems go up to 16MB.
+       // Since this is only a limit, it is safe to make it optimistic.
+       bdpLimit = (1 << 20) * 16
        // alpha is a constant factor used to keep a moving average
        // of RTTs.
        alpha = 0.9
@@ -41,12 +42,9 @@ const (
        gamma = 2
 )
 
-var (
-       // Adding arbitrary data to ping so that its ack can be
-       // identified.
-       // Easter-egg: what does the ping message say?
-       bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}}
-)
+// Adding arbitrary data to ping so that its ack can be identified.
+// Easter-egg: what does the ping message say?
+var bdpPing = &ping{data: [8]byte{2, 4, 16, 16, 9, 14, 7, 7}}
 
 type bdpEstimator struct {
        // sentAt is the time when the ping was sent.
@@ -59,7 +57,7 @@ type bdpEstimator struct {
        sample uint32
        // bwMax is the maximum bandwidth noted so far (bytes/sec).
        bwMax float64
-       // bool to keep track of the begining of a new measurement cycle.
+       // bool to keep track of the beginning of a new measurement cycle.
        isSent bool
        // Callback to update the window sizes.
        updateFlowControl func(n uint32)
@@ -70,7 +68,7 @@ type bdpEstimator struct {
 }
 
 // timesnap registers the time bdp ping was sent out so that
-// network rtt can be calculated when its ack is recieved.
+// network rtt can be calculated when its ack is received.
 // It is called (by controller) when the bdpPing is
 // being written on the wire.
 func (b *bdpEstimator) timesnap(d [8]byte) {
@@ -119,7 +117,7 @@ func (b *bdpEstimator) calculate(d [8]byte) {
                b.rtt += (rttSample - b.rtt) * float64(alpha)
        }
        b.isSent = false
-       // The number of bytes accumalated so far in the sample is smaller
+       // The number of bytes accumulated so far in the sample is smaller
        // than or equal to 1.5 times the real BDP on a saturated connection.
        bwCurrent := float64(b.sample) / (b.rtt * float64(1.5))
        if bwCurrent > b.bwMax {