Skip to content

Commit

Permalink
change the history cache key name to *Bytes (#4649)
Browse files Browse the repository at this point in the history
<!-- Describe what has changed in this PR -->
**What changed?**
change history cache key from history.eventsCache*Size to
history.eventsCache*SizeBytes

<!-- Tell your future self why have you made these changes -->
It will remove the key name confusion since cache size definition
changed in: #4621

<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
unittests

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
  • Loading branch information
yujieli-temporal authored and wxing1292 committed Jul 22, 2023
1 parent c4a3cc8 commit 31ae692
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 37 deletions.
1 change: 0 additions & 1 deletion common/cache/lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"time"

"github.com/google/uuid"
"github.com/jonboulle/clockwork"
"github.com/stretchr/testify/assert"
)

Expand Down
8 changes: 4 additions & 4 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions service/history/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions service/history/historyEngine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions service/history/replication/ack_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/shard/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/timerQueueActiveTaskExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/timerQueueStandbyTaskExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/transferQueueActiveTaskExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/transferQueueStandbyTaskExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions service/history/visibilityQueueTaskExecutor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 31ae692

Please sign in to comment.