From 1564a8698cf8af374d42448a595981129964b148 Mon Sep 17 00:00:00 2001 From: Edoardo Spadolini Date: Tue, 12 Nov 2024 23:06:03 +0100 Subject: [PATCH] Replace sharded jitters with thread-local ones --- e | 2 +- lib/inventory/controller.go | 9 +++++---- lib/inventory/helpers.go | 33 --------------------------------- 3 files changed, 6 insertions(+), 38 deletions(-) delete mode 100644 lib/inventory/helpers.go diff --git a/e b/e index 735e2750358ed..7c39e2ed45222 160000 --- a/e +++ b/e @@ -1 +1 @@ -Subproject commit 735e2750358edf437cf1778d79436b04cb7d388f +Subproject commit 7c39e2ed45222c319bbf4810d4ebd4e8453ee07d diff --git a/lib/inventory/controller.go b/lib/inventory/controller.go index 71868b6da189a..274a0d9a4af01 100644 --- a/lib/inventory/controller.go +++ b/lib/inventory/controller.go @@ -33,6 +33,7 @@ import ( "github.com/gravitational/teleport/api/constants" apidefaults "github.com/gravitational/teleport/api/defaults" "github.com/gravitational/teleport/api/types" + "github.com/gravitational/teleport/api/utils/retryutils" usagereporter "github.com/gravitational/teleport/lib/usagereporter/teleport" "github.com/gravitational/teleport/lib/utils" "github.com/gravitational/teleport/lib/utils/interval" @@ -294,8 +295,8 @@ func (c *Controller) RegisterControlStream(stream client.UpstreamInventoryContro interval.SubInterval[intervalKey]{ Key: instanceHeartbeatKey, VariableDuration: c.instanceHBVariableDuration, - FirstDuration: fullJitter(c.instanceHBVariableDuration.Duration()), - Jitter: seventhJitter, + FirstDuration: retryutils.FullJitter(c.instanceHBVariableDuration.Duration()), + Jitter: retryutils.SeventhJitter, }) handle := newUpstreamHandle(stream, hello, ticker) c.store.Insert(handle) @@ -430,8 +431,8 @@ func (c *Controller) handleControlStream(handle *upstreamHandle) { handle.ticker.Push(interval.SubInterval[intervalKey]{ Key: serverKeepAliveKey, Duration: c.serverKeepAlive, - FirstDuration: halfJitter(c.serverKeepAlive), - Jitter: seventhJitter, + FirstDuration: retryutils.HalfJitter(c.serverKeepAlive), + Jitter: retryutils.SeventhJitter, }) keepAliveNeedInit = false } diff --git a/lib/inventory/helpers.go b/lib/inventory/helpers.go deleted file mode 100644 index 4f97476573731..0000000000000 --- a/lib/inventory/helpers.go +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Teleport - * Copyright (C) 2023 Gravitational, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package inventory - -import ( - "github.com/gravitational/teleport/api/utils/retryutils" -) - -// we use dedicated global jitters for all the intervals/retries in this -// package. we do this because our jitter usage in this package can scale by -// the number of concurrent connections to auth, making dedicated jitters a -// poor choice (high memory usage for all the rngs). -var ( - seventhJitter = retryutils.NewShardedSeventhJitter() - halfJitter = retryutils.NewShardedHalfJitter() - fullJitter = retryutils.NewShardedFullJitter() -)