Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
const shardCount = 1024

type cacheSettings struct {
maxSize int32
maxSize int64
xlog io.Writer
tagsEnabled bool
}
Expand All @@ -50,7 +50,7 @@ type Cache struct {
settings atomic.Value // cacheSettings

stat struct {
size int32 // changing via atomic
size int64 // changing via atomic
queueBuildCnt uint32 // number of times writeout queue was built
queueBuildTimeMs uint32 // time spent building writeout queue in milliseconds
queueWriteoutTime uint32 // in milliseconds
Expand Down Expand Up @@ -129,10 +129,10 @@ func (c *Cache) SetWriteStrategy(s string) (err error) {
}

// SetMaxSize of cache
func (c *Cache) SetMaxSize(maxSize uint32) {
func (c *Cache) SetMaxSize(maxSize uint64) {
s := c.settings.Load().(*cacheSettings)
newSettings := *s
newSettings.maxSize = int32(maxSize)
newSettings.maxSize = int64(maxSize)
c.settings.Store(&newSettings)
}

Expand Down Expand Up @@ -274,8 +274,8 @@ func (c *Cache) NotConfirmedLength() int32 {
return int32(l)
}

func (c *Cache) Size() int32 {
return atomic.LoadInt32(&c.stat.size)
func (c *Cache) Size() int64 {
return atomic.LoadInt64(&c.stat.size)
}

func (c *Cache) DivertToXlog(w io.Writer) {
Expand Down Expand Up @@ -353,7 +353,7 @@ func (c *Cache) Add(p *points.Points) {
}

}
atomic.AddInt32(&c.stat.size, int32(count))
atomic.AddInt64(&c.stat.size, int64(count))
}

// Pop removes an element from the map and returns it
Expand All @@ -366,7 +366,7 @@ func (c *Cache) Pop(key string) (p *points.Points, exists bool) {
shard.Unlock()

if exists {
atomic.AddInt32(&c.stat.size, -int32(len(p.Data)))
atomic.AddInt64(&c.stat.size, -int64(len(p.Data)))
}

return p, exists
Expand All @@ -390,7 +390,7 @@ func (c *Cache) PopNotConfirmed(key string) (p *points.Points, exists bool) {
shard.Unlock()

if exists {
atomic.AddInt32(&c.stat.size, -int32(len(p.Data)))
atomic.AddInt64(&c.stat.size, -int64(len(p.Data)))
}

return p, exists
Expand Down
2 changes: 1 addition & 1 deletion cache/dump_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func fillCacheForDump() *Cache {
pointsCount := 5

c := New()
c.SetMaxSize(uint32(pointsCount*metrics + 1))
c.SetMaxSize(uint64(pointsCount*metrics + 1))

baseTimestamp := time.Now().Unix()

Expand Down
2 changes: 1 addition & 1 deletion carbon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type whisperConfig struct {
}

type cacheConfig struct {
MaxSize uint32 `toml:"max-size"`
MaxSize uint64 `toml:"max-size"`
WriteStrategy string `toml:"write-strategy"`
BloomSize uint64 `toml:"bloom-size"`
}
Expand Down
2 changes: 1 addition & 1 deletion carbon/grace.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (app *App) DumpStop() error {
}

logger.Info("cache dump finished",
zap.Int("records", int(cacheSize)),
zap.Int64("records", int64(cacheSize)),
zap.Duration("runtime", time.Since(dumpStart)),
)

Expand Down
Loading