diff --git a/common/cache/cache.go b/common/cache/cache.go index 044f951bd349..1185fcbaa9c7 100644 --- a/common/cache/cache.go +++ b/common/cache/cache.go @@ -64,9 +64,6 @@ type Options struct { // are older than the TTL will not be returned. TTL time.Duration - // InitialCapacity controls the initial capacity of the cache - InitialCapacity int - // Pin prevents in-use objects from getting evicted. Pin bool diff --git a/common/cache/lru.go b/common/cache/lru.go index 541cfeb35cc3..001572eea893 100644 --- a/common/cache/lru.go +++ b/common/cache/lru.go @@ -152,7 +152,7 @@ func New(maxSize int, opts *Options) Cache { return &lru{ byAccess: list.New(), - byKey: make(map[interface{}]*list.Element, opts.InitialCapacity), + byKey: make(map[interface{}]*list.Element), ttl: opts.TTL, maxSize: maxSize, currSize: 0, @@ -167,14 +167,6 @@ func NewLRU(maxSize int) Cache { return New(maxSize, nil) } -// NewLRUWithInitialCapacity creates a new LRU cache with an initial capacity -// and a max size -func NewLRUWithInitialCapacity(initialCapacity, maxSize int) Cache { - return New(maxSize, &Options{ - InitialCapacity: initialCapacity, - }) -} - // Get retrieves the value stored under the given key func (c *lru) Get(key interface{}) interface{} { if c.maxSize == 0 { // diff --git a/common/dynamicconfig/constants.go b/common/dynamicconfig/constants.go index 549c052117a8..583abc5a66ef 100644 --- a/common/dynamicconfig/constants.go +++ b/common/dynamicconfig/constants.go @@ -493,8 +493,6 @@ const ( HistoryShutdownDrainDuration = "history.shutdownDrainDuration" // XDCCacheMaxSizeBytes is max size of events cache in bytes XDCCacheMaxSizeBytes = "history.xdcCacheMaxSizeBytes" - // EventsCacheInitialKeySize is initial count of keys for events cache - EventsCacheInitialKeySize = "history.eventsCacheInitialKeySize" // EventsCacheMaxValueSizeBytes is max size of events cache in bytes EventsCacheMaxValueSizeBytes = "history.eventsCacheMaxValueSizeBytes" // EventsCacheTTL is TTL of events cache diff --git a/service/history/configs/config.go b/service/history/configs/config.go index 1d4208cf048f..2816e8636360 100644 --- a/service/history/configs/config.go +++ b/service/history/configs/config.go @@ -360,9 +360,8 @@ func NewConfig( HistoryCacheTTL: dc.GetDurationProperty(dynamicconfig.HistoryCacheTTL, time.Hour), HistoryCacheNonUserContextLockTimeout: dc.GetDurationProperty(dynamicconfig.HistoryCacheNonUserContextLockTimeout, 500*time.Millisecond), - EventsCacheInitialKeySize: dc.GetIntProperty(dynamicconfig.EventsCacheInitialKeySize, 128), - EventsCacheMaxSizeBytes: dc.GetIntProperty(dynamicconfig.EventsCacheMaxValueSizeBytes, 512*1024), // 512KB - EventsCacheTTL: dc.GetDurationProperty(dynamicconfig.EventsCacheTTL, time.Hour), + EventsCacheMaxSizeBytes: dc.GetIntProperty(dynamicconfig.EventsCacheMaxValueSizeBytes, 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), diff --git a/service/history/events/cache.go b/service/history/events/cache.go index 685c4282c552..dfb0ae3df191 100644 --- a/service/history/events/cache.go +++ b/service/history/events/cache.go @@ -79,7 +79,6 @@ var _ Cache = (*CacheImpl)(nil) func NewEventsCache( shardID int32, - initialCount int, maxCount int, ttl time.Duration, eventsMgr persistence.ExecutionManager, @@ -88,7 +87,6 @@ func NewEventsCache( metricsHandler metrics.Handler, ) *CacheImpl { opts := &cache.Options{} - opts.InitialCapacity = initialCount opts.TTL = ttl return &CacheImpl{ diff --git a/service/history/events/cache_test.go b/service/history/events/cache_test.go index 0353078c9799..8387908a56ec 100644 --- a/service/history/events/cache_test.go +++ b/service/history/events/cache_test.go @@ -89,7 +89,6 @@ func (s *eventsCacheSuite) newTestEventsCache() *CacheImpl { shardId := int32(10) return NewEventsCache( shardId, - 16, 32, time.Minute, s.mockExecutionManager, diff --git a/service/history/history_engine_test.go b/service/history/history_engine_test.go index af457c6a40e7..a9248e8e67e3 100644 --- a/service/history/history_engine_test.go +++ b/service/history/history_engine_test.go @@ -161,7 +161,6 @@ func (s *engineSuite) SetupTest() { s.eventsCache = events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/replication/ack_manager_test.go b/service/history/replication/ack_manager_test.go index 53a1795367b9..cb3ce030e4c2 100644 --- a/service/history/replication/ack_manager_test.go +++ b/service/history/replication/ack_manager_test.go @@ -307,7 +307,6 @@ func (s *ackManagerSuite) TestGetTasks_SecondPersistenceErrorReturnsPartialResul eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), @@ -359,7 +358,6 @@ func (s *ackManagerSuite) TestGetTasks_FullPage() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), @@ -411,7 +409,6 @@ func (s *ackManagerSuite) TestGetTasks_PartialPage() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), @@ -500,7 +497,6 @@ func (s *ackManagerSuite) TestGetTasks_FilterNamespace() { eventsCache := events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/shard/context_impl.go b/service/history/shard/context_impl.go index 44719073007b..12b3bff69e55 100644 --- a/service/history/shard/context_impl.go +++ b/service/history/shard/context_impl.go @@ -1957,7 +1957,6 @@ func newContext( } shardContext.eventsCache = events.NewEventsCache( shardContext.GetShardID(), - shardContext.GetConfig().EventsCacheInitialKeySize(), shardContext.GetConfig().EventsCacheMaxSizeBytes(), shardContext.GetConfig().EventsCacheTTL(), shardContext.GetExecutionManager(), diff --git a/service/history/timer_queue_active_task_executor_test.go b/service/history/timer_queue_active_task_executor_test.go index 9c5223a358f2..46decc22211b 100644 --- a/service/history/timer_queue_active_task_executor_test.go +++ b/service/history/timer_queue_active_task_executor_test.go @@ -139,7 +139,6 @@ func (s *timerQueueActiveTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/timer_queue_standby_task_executor_test.go b/service/history/timer_queue_standby_task_executor_test.go index 1f597d6dcee2..1aa0b862fbb5 100644 --- a/service/history/timer_queue_standby_task_executor_test.go +++ b/service/history/timer_queue_standby_task_executor_test.go @@ -142,7 +142,6 @@ func (s *timerQueueStandbyTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/transfer_queue_active_task_executor_test.go b/service/history/transfer_queue_active_task_executor_test.go index 6facf3754ee9..1abbf83e3067 100644 --- a/service/history/transfer_queue_active_task_executor_test.go +++ b/service/history/transfer_queue_active_task_executor_test.go @@ -175,7 +175,6 @@ func (s *transferQueueActiveTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/transfer_queue_standby_task_executor_test.go b/service/history/transfer_queue_standby_task_executor_test.go index 6bd2d1a0e214..1a3528f76ff4 100644 --- a/service/history/transfer_queue_standby_task_executor_test.go +++ b/service/history/transfer_queue_standby_task_executor_test.go @@ -149,7 +149,6 @@ func (s *transferQueueStandbyTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/visibility_queue_task_executor_test.go b/service/history/visibility_queue_task_executor_test.go index 1dac34a31449..c1bd09ff23c6 100644 --- a/service/history/visibility_queue_task_executor_test.go +++ b/service/history/visibility_queue_task_executor_test.go @@ -121,7 +121,6 @@ func (s *visibilityQueueTaskExecutorSuite) SetupTest() { ) s.mockShard.SetEventsCacheForTesting(events.NewEventsCache( s.mockShard.GetShardID(), - s.mockShard.GetConfig().EventsCacheInitialKeySize(), s.mockShard.GetConfig().EventsCacheMaxSizeBytes(), s.mockShard.GetConfig().EventsCacheTTL(), s.mockShard.GetExecutionManager(), diff --git a/service/history/workflow/cache/cache.go b/service/history/workflow/cache/cache.go index b4dc87253dc9..7dc65675d8b5 100644 --- a/service/history/workflow/cache/cache.go +++ b/service/history/workflow/cache/cache.go @@ -98,7 +98,6 @@ const ( func NewCache(shard shard.Context) Cache { opts := &cache.Options{} config := shard.GetConfig() - opts.InitialCapacity = config.HistoryCacheInitialSize() opts.TTL = config.HistoryCacheTTL() opts.Pin = true