[arvados] created: 2.6.0-195-gf3b528961

git repository hosting git at public.arvados.org
Thu May 25 15:25:48 UTC 2023


        at  f3b5289610db5f0b54c73ff5ec0cd80e51f1ae94 (commit)


commit f3b5289610db5f0b54c73ff5ec0cd80e51f1ae94
Author: Tom Clegg <tom at curii.com>
Date:   Thu May 25 11:25:02 2023 -0400

    20511: Limit server-to-server client to 1/4 of API req capacity.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/client.go b/sdk/go/arvados/client.go
index d1a87e30e..6316d1bed 100644
--- a/sdk/go/arvados/client.go
+++ b/sdk/go/arvados/client.go
@@ -142,11 +142,12 @@ func NewClientFromConfig(cluster *Cluster) (*Client, error) {
 		}
 	}
 	return &Client{
-		Client:   hc,
-		Scheme:   ctrlURL.Scheme,
-		APIHost:  ctrlURL.Host,
-		Insecure: cluster.TLS.Insecure,
-		Timeout:  5 * time.Minute,
+		Client:         hc,
+		Scheme:         ctrlURL.Scheme,
+		APIHost:        ctrlURL.Host,
+		Insecure:       cluster.TLS.Insecure,
+		Timeout:        5 * time.Minute,
+		requestLimiter: requestLimiter{maxlimit: int64(cluster.API.MaxConcurrentRequests / 4)},
 	}, nil
 }
 
diff --git a/sdk/go/arvados/limiter.go b/sdk/go/arvados/limiter.go
index 0fc6cc096..dc944160a 100644
--- a/sdk/go/arvados/limiter.go
+++ b/sdk/go/arvados/limiter.go
@@ -21,6 +21,7 @@ var (
 type requestLimiter struct {
 	current    int64
 	limit      int64
+	maxlimit   int64
 	lock       sync.Mutex
 	cond       *sync.Cond
 	quietUntil time.Time
@@ -144,6 +145,9 @@ func (rl *requestLimiter) Report(resp *http.Response, err error) bool {
 		if max := rl.current * 2; max < rl.limit {
 			rl.limit = max
 		}
+		if rl.maxlimit > 0 && rl.maxlimit < rl.limit {
+			rl.limit = rl.maxlimit
+		}
 		rl.cond.Broadcast()
 	}
 	return false

commit 084cf674057c118b0ffade9f6502a0c559d04582
Author: Tom Clegg <tom at curii.com>
Date:   Thu May 25 10:33:53 2023 -0400

    20511: Fix slow-expansion logic.
    
    Limit was always being raised to 2x known-working, instead of
    min(+10%, 2x known-working) as intended.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/limiter.go b/sdk/go/arvados/limiter.go
index ac244593b..0fc6cc096 100644
--- a/sdk/go/arvados/limiter.go
+++ b/sdk/go/arvados/limiter.go
@@ -141,7 +141,7 @@ func (rl *requestLimiter) Report(resp *http.Response, err error) bool {
 			increase = 1
 		}
 		rl.limit += increase
-		if max := rl.current * 2; max > rl.limit {
+		if max := rl.current * 2; max < rl.limit {
 			rl.limit = max
 		}
 		rl.cond.Broadcast()

commit 6bcd1910537f4f24eebb21995e770d7ea6153462
Author: Tom Clegg <tom at curii.com>
Date:   Thu May 25 10:12:40 2023 -0400

    20511: Start with 8 concurrent outgoing API calls, not unlimited.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/go/arvados/limiter.go b/sdk/go/arvados/limiter.go
index f62264c63..ac244593b 100644
--- a/sdk/go/arvados/limiter.go
+++ b/sdk/go/arvados/limiter.go
@@ -13,7 +13,10 @@ import (
 	"time"
 )
 
-var requestLimiterQuietPeriod = time.Second
+var (
+	requestLimiterQuietPeriod        = time.Second
+	requestLimiterInitialLimit int64 = 8
+)
 
 type requestLimiter struct {
 	current    int64
@@ -33,6 +36,7 @@ func (rl *requestLimiter) Acquire(ctx context.Context) {
 	if rl.cond == nil {
 		// First use of requestLimiter. Initialize.
 		rl.cond = sync.NewCond(&rl.lock)
+		rl.limit = requestLimiterInitialLimit
 	}
 	// Wait out the quiet period(s) immediately following a 503.
 	for ctx.Err() == nil {
diff --git a/sdk/go/arvados/limiter_test.go b/sdk/go/arvados/limiter_test.go
index d32ab9699..1e73b1c28 100644
--- a/sdk/go/arvados/limiter_test.go
+++ b/sdk/go/arvados/limiter_test.go
@@ -18,23 +18,23 @@ var _ = Suite(&limiterSuite{})
 
 type limiterSuite struct{}
 
-func (*limiterSuite) TestUnlimitedBeforeFirstReport(c *C) {
+func (*limiterSuite) TestInitialLimit(c *C) {
 	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Minute))
 	defer cancel()
 	rl := requestLimiter{}
 
 	var wg sync.WaitGroup
-	wg.Add(1000)
-	for i := 0; i < 1000; i++ {
+	wg.Add(int(requestLimiterInitialLimit))
+	for i := int64(0); i < requestLimiterInitialLimit; i++ {
 		go func() {
 			rl.Acquire(ctx)
 			wg.Done()
 		}()
 	}
 	wg.Wait()
-	c.Check(rl.current, Equals, int64(1000))
-	wg.Add(1000)
-	for i := 0; i < 1000; i++ {
+	c.Check(rl.current, Equals, requestLimiterInitialLimit)
+	wg.Add(int(requestLimiterInitialLimit))
+	for i := int64(0); i < requestLimiterInitialLimit; i++ {
 		go func() {
 			rl.Release()
 			wg.Done()
@@ -49,8 +49,8 @@ func (*limiterSuite) TestCancelWhileWaitingForAcquire(c *C) {
 	defer cancel()
 	rl := requestLimiter{}
 
-	rl.limit = 1
 	rl.Acquire(ctx)
+	rl.limit = 1
 	ctxShort, cancel := context.WithDeadline(ctx, time.Now().Add(time.Millisecond))
 	defer cancel()
 	rl.Acquire(ctxShort)
@@ -74,7 +74,7 @@ func (*limiterSuite) TestReducedLimitAndQuietPeriod(c *C) {
 		rl.Acquire(ctx)
 	}
 	rl.Report(&http.Response{StatusCode: http.StatusServiceUnavailable}, nil)
-	c.Check(rl.limit, Equals, int64(3))
+	c.Check(rl.limit, Equals, requestLimiterInitialLimit/2)
 	for i := 0; i < 5; i++ {
 		rl.Release()
 	}

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list