Skip to content

Commit

Permalink
remove the event cache init size key
Browse files Browse the repository at this point in the history
  • Loading branch information
yujieli-temporal committed Aug 2, 2023
1 parent 82b78cc commit d87805f
Show file tree
Hide file tree
Showing 18 changed files with 11 additions and 45 deletions.
3 changes: 0 additions & 3 deletions common/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 1 addition & 9 deletions common/cache/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 { //
Expand Down
2 changes: 0 additions & 2 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions common/namespace/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ const (
)

const (
cacheInitialSize = 10 * 1024
cacheMaxSize = 64 * 1024
cacheTTL = 0 // 0 means infinity
cacheMaxSize = 64 * 1024
cacheTTL = 0 // 0 means infinity
// CacheRefreshFailureRetryInterval is the wait time
// if refreshment encounters error
CacheRefreshFailureRetryInterval = 1 * time.Second
Expand All @@ -78,12 +77,10 @@ const (

var (
cacheOpts = cache.Options{
InitialCapacity: cacheInitialSize,
TTL: cacheTTL,
TTL: cacheTTL,
}
readthroughNotFoundCacheOpts = cache.Options{
InitialCapacity: cacheInitialSize,
TTL: readthroughCacheTTL,
TTL: readthroughCacheTTL,
}
)

Expand Down
5 changes: 2 additions & 3 deletions common/persistence/xdc_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,8 @@ func NewEventsBlobCache(
) *XDCCacheImpl {
return &XDCCacheImpl{
cache: cache.New(util.Max(xdcMinCacheSize, maxBytes), &cache.Options{
InitialCapacity: xdcMinCacheSize,
TTL: ttl,
Pin: false,
TTL: ttl,
Pin: false,
}),
}
}
Expand Down
5 changes: 2 additions & 3 deletions service/history/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,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),
Expand Down
2 changes: 0 additions & 2 deletions service/history/events/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ var _ Cache = (*CacheImpl)(nil)

func NewEventsCache(
shardID int32,
initialCount int,
maxCount int,
ttl time.Duration,
eventsMgr persistence.ExecutionManager,
Expand All @@ -88,7 +87,6 @@ func NewEventsCache(
metricsHandler metrics.Handler,
) *CacheImpl {
opts := &cache.Options{}
opts.InitialCapacity = initialCount
opts.TTL = ttl

return &CacheImpl{
Expand Down
1 change: 0 additions & 1 deletion service/history/events/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func (s *eventsCacheSuite) newTestEventsCache() *CacheImpl {
shardId := int32(10)
return NewEventsCache(
shardId,
16,
32,
time.Minute,
s.mockExecutionManager,
Expand Down
1 change: 0 additions & 1 deletion service/history/history_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 0 additions & 4 deletions service/history/replication/ack_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion service/history/shard/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,6 @@ func newContext(
}
shardContext.eventsCache = events.NewEventsCache(
shardContext.GetShardID(),
shardContext.GetConfig().EventsCacheInitialKeySize(),
shardContext.GetConfig().EventsCacheMaxSizeBytes(),
shardContext.GetConfig().EventsCacheTTL(),
shardContext.GetExecutionManager(),
Expand Down
1 change: 0 additions & 1 deletion service/history/timer_queue_active_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion service/history/timer_queue_standby_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion service/history/visibility_queue_task_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 0 additions & 1 deletion service/history/workflow/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions service/matching/poller_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ type pollerHistory struct {

func newPollerHistory() *pollerHistory {
opts := &cache.Options{
InitialCapacity: pollerHistoryInitSize,
TTL: pollerHistoryTTL,
Pin: false,
TTL: pollerHistoryTTL,
Pin: false,
}

return &pollerHistory{
Expand Down

0 comments on commit d87805f

Please sign in to comment.