From 31ae69213a1687db31836b054417da26ac297033 Mon Sep 17 00:00:00 2001 From: Yujie Li <120415427+yujieli-temporal@users.noreply.github.com> Date: Wed, 19 Jul 2023 10:31:40 -0700 Subject: [PATCH] change the history cache key name to *Bytes (#4649) **What changed?** change history cache key from history.eventsCache*Size to history.eventsCache*SizeBytes It will remove the key name confusion since cache size definition changed in: https://github.com/temporalio/temporal/pull/4621 unittests **Potential risks** **Is hotfix candidate?** --- common/cache/lru_test.go | 1 - common/dynamicconfig/constants.go | 8 +++---- service/history/configs/config.go | 22 ++++++++++--------- service/history/historyEngine_test.go | 4 ++-- .../history/replication/ack_manager_test.go | 16 +++++++------- service/history/shard/context_impl.go | 4 ++-- .../timerQueueActiveTaskExecutor_test.go | 4 ++-- .../timerQueueStandbyTaskExecutor_test.go | 4 ++-- .../transferQueueActiveTaskExecutor_test.go | 4 ++-- .../transferQueueStandbyTaskExecutor_test.go | 4 ++-- .../visibilityQueueTaskExecutor_test.go | 4 ++-- 11 files changed, 38 insertions(+), 37 deletions(-) diff --git a/common/cache/lru_test.go b/common/cache/lru_test.go index 00a3d35354a4..dee27c5eb449 100644 --- a/common/cache/lru_test.go +++ b/common/cache/lru_test.go @@ -31,7 +31,6 @@ import ( "time" "github.com/google/uuid" - "github.com/jonboulle/clockwork" "github.com/stretchr/testify/assert" ) diff --git a/common/dynamicconfig/constants.go b/common/dynamicconfig/constants.go index feb0cc5d2786..33351e070025 100644 --- a/common/dynamicconfig/constants.go +++ b/common/dynamicconfig/constants.go @@ -477,10 +477,10 @@ const ( HistoryCacheTTL = "history.cacheTTL" // HistoryShutdownDrainDuration is the duration of traffic drain during shutdown HistoryShutdownDrainDuration = "history.shutdownDrainDuration" - // EventsCacheInitialSize is initial size of events cache - EventsCacheInitialSize = "history.eventsCacheInitialSize" - // EventsCacheMaxSize is max size of events cache - EventsCacheMaxSize = "history.eventsCacheMaxSize" + // EventsCacheInitialSizeBytes is initial size of events cache in bytes + EventsCacheInitialSizeBytes = "history.eventsCacheInitialSizeBytes" + // EventsCacheMaxSizeBytes is max size of events cache in bytes + EventsCacheMaxSizeBytes = "history.eventsCacheMaxSizeBytes" // EventsCacheTTL is TTL of events cache EventsCacheTTL = "history.eventsCacheTTL" // AcquireShardInterval is interval that timer used to acquire shard diff --git a/service/history/configs/config.go b/service/history/configs/config.go index fa17c545960f..fa9921970733 100644 --- a/service/history/configs/config.go +++ b/service/history/configs/config.go @@ -71,9 +71,9 @@ type Config struct { // EventsCache settings // Change of these configs require shard restart - EventsCacheInitialSize dynamicconfig.IntPropertyFn - EventsCacheMaxSize dynamicconfig.IntPropertyFn - EventsCacheTTL dynamicconfig.DurationPropertyFn + EventsCacheInitialSizeBytes dynamicconfig.IntPropertyFn + EventsCacheMaxSizeBytes dynamicconfig.IntPropertyFn + EventsCacheTTL dynamicconfig.DurationPropertyFn // ShardController settings RangeSizeBits uint @@ -345,13 +345,15 @@ func NewConfig( VisibilityDisableOrderByClause: dc.GetBoolPropertyFnWithNamespaceFilter(dynamicconfig.VisibilityDisableOrderByClause, true), VisibilityEnableManualPagination: dc.GetBoolPropertyFnWithNamespaceFilter(dynamicconfig.VisibilityEnableManualPagination, true), - EmitShardLagLog: dc.GetBoolProperty(dynamicconfig.EmitShardLagLog, false), - HistoryCacheInitialSize: dc.GetIntProperty(dynamicconfig.HistoryCacheInitialSize, 128), - HistoryCacheMaxSize: dc.GetIntProperty(dynamicconfig.HistoryCacheMaxSize, 512), - HistoryCacheTTL: dc.GetDurationProperty(dynamicconfig.HistoryCacheTTL, time.Hour), - EventsCacheInitialSize: dc.GetIntProperty(dynamicconfig.EventsCacheInitialSize, 128*1024), // 128KB - EventsCacheMaxSize: dc.GetIntProperty(dynamicconfig.EventsCacheMaxSize, 512*1024), // 512KB - EventsCacheTTL: dc.GetDurationProperty(dynamicconfig.EventsCacheTTL, time.Hour), + EmitShardLagLog: dc.GetBoolProperty(dynamicconfig.EmitShardLagLog, false), + HistoryCacheInitialSize: dc.GetIntProperty(dynamicconfig.HistoryCacheInitialSize, 128), + HistoryCacheMaxSize: dc.GetIntProperty(dynamicconfig.HistoryCacheMaxSize, 512), + HistoryCacheTTL: dc.GetDurationProperty(dynamicconfig.HistoryCacheTTL, time.Hour), + + EventsCacheInitialSizeBytes: dc.GetIntProperty(dynamicconfig.EventsCacheInitialSizeBytes, 128*1024), // 128KB + EventsCacheMaxSizeBytes: dc.GetIntProperty(dynamicconfig.EventsCacheMaxSizeBytes, 512*1024), // 512KB + EventsCacheTTL: dc.GetDurationProperty(dynamicconfig.EventsCacheTTL, time.Hour), + RangeSizeBits: 20, // 20 bits for sequencer, 2^20 sequence number for any range AcquireShardInterval: dc.GetDurationProperty(dynamicconfig.AcquireShardInterval, time.Minute), AcquireShardConcurrency: dc.GetIntProperty(dynamicconfig.AcquireShardConcurrency, 10), diff --git a/service/history/historyEngine_test.go b/service/history/historyEngine_test.go index 0268f2cc079a..a8715e53d8c1 100644 --- a/service/history/historyEngine_test.go +++ b/service/history/historyEngine_test.go @@ -161,8 +161,8 @@ func (s *engineSuite) SetupTest() { s.eventsCache = events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/replication/ack_manager_test.go b/service/history/replication/ack_manager_test.go index 461ee60a72b8..c7237e1a7f1f 100644 --- a/service/history/replication/ack_manager_test.go +++ b/service/history/replication/ack_manager_test.go @@ -307,8 +307,8 @@ func (s *ackManagerSuite) TestGetTasks_SecondPersistenceErrorReturnsPartialResul eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, @@ -359,8 +359,8 @@ func (s *ackManagerSuite) TestGetTasks_FullPage() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, @@ -411,8 +411,8 @@ func (s *ackManagerSuite) TestGetTasks_PartialPage() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, @@ -500,8 +500,8 @@ func (s *ackManagerSuite) TestGetTasks_FilterNamespace() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/shard/context_impl.go b/service/history/shard/context_impl.go index bc16fda47782..2edc7c1f1c95 100644 --- a/service/history/shard/context_impl.go +++ b/service/history/shard/context_impl.go @@ -1935,8 +1935,8 @@ func newContext( } shardContext.eventsCache = events.NewEventsCache( shardContext.GetShardID(), - shardContext.GetConfig().EventsCacheInitialSize(), - shardContext.GetConfig().EventsCacheMaxSize(), + shardContext.GetConfig().EventsCacheInitialSizeBytes(), + shardContext.GetConfig().EventsCacheMaxSizeBytes(), shardContext.GetConfig().EventsCacheTTL(), shardContext.GetExecutionManager(), false, diff --git a/service/history/timerQueueActiveTaskExecutor_test.go b/service/history/timerQueueActiveTaskExecutor_test.go index feaa20a6ff7c..547c9343d087 100644 --- a/service/history/timerQueueActiveTaskExecutor_test.go +++ b/service/history/timerQueueActiveTaskExecutor_test.go @@ -138,8 +138,8 @@ func (s *timerQueueActiveTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/timerQueueStandbyTaskExecutor_test.go b/service/history/timerQueueStandbyTaskExecutor_test.go index 137a75b35972..493b0708c05d 100644 --- a/service/history/timerQueueStandbyTaskExecutor_test.go +++ b/service/history/timerQueueStandbyTaskExecutor_test.go @@ -141,8 +141,8 @@ func (s *timerQueueStandbyTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/transferQueueActiveTaskExecutor_test.go b/service/history/transferQueueActiveTaskExecutor_test.go index 78d80c606eb4..40e452730f95 100644 --- a/service/history/transferQueueActiveTaskExecutor_test.go +++ b/service/history/transferQueueActiveTaskExecutor_test.go @@ -174,8 +174,8 @@ func (s *transferQueueActiveTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/transferQueueStandbyTaskExecutor_test.go b/service/history/transferQueueStandbyTaskExecutor_test.go index 89274d95dd6d..4bd1992d35c8 100644 --- a/service/history/transferQueueStandbyTaskExecutor_test.go +++ b/service/history/transferQueueStandbyTaskExecutor_test.go @@ -149,8 +149,8 @@ func (s *transferQueueStandbyTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false, diff --git a/service/history/visibilityQueueTaskExecutor_test.go b/service/history/visibilityQueueTaskExecutor_test.go index bc1b83cacd38..89550bef312e 100644 --- a/service/history/visibilityQueueTaskExecutor_test.go +++ b/service/history/visibilityQueueTaskExecutor_test.go @@ -121,8 +121,8 @@ func (s *visibilityQueueTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialSize(), - s.mockShard.GetConfig().EventsCacheMaxSize(), + s.mockShard.GetConfig().EventsCacheInitialSizeBytes(), + s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), false,