Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use fastcache #164

Merged
merged 23 commits into from
May 10, 2021
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c043c53
feat: use fastcache for interblock cache
Apr 23, 2021
562174d
feat: add prometheus metric
May 1, 2021
db2306b
Merge branch 'v2/develop' of https://github.com/line/lbm-sdk into ego…
May 1, 2021
9e3351d
feat: add more cache metric; bytes size, entry count
May 1, 2021
95adf64
chore: param caching
May 3, 2021
8bf47ea
Merge branch 'v2/develop' of github.com:line/lbm-sdk into egon/v2/fea…
May 4, 2021
b2bb4f9
feat: use fastcache as iavl nodedb cache
May 7, 2021
99c6288
Merge branch 'egon/v2/feat/fastcache' of github.com:line/lbm-sdk into…
May 7, 2021
1acc5cb
chore: remove debugging code; fix lint error
May 7, 2021
f3fc0ab
chore: fix lint error
May 7, 2021
9c77242
chore: raise codecov
May 7, 2021
107bd0a
chore: raise codecov, modify metric description
May 7, 2021
26be108
chore: raise codecov
May 7, 2021
33d3286
chore: disable Pseudo-Comparison of codecov
May 7, 2021
3a29814
chore: trying codecov to succeed
May 7, 2021
dfb5072
chore: release threashold of coverage to update base report
May 7, 2021
69c7077
chore: trying codecov to succeed
May 7, 2021
fc9ea35
Merge branch 'v2/develop' of github.com:line/lbm-sdk into egon/v2/fea…
May 7, 2021
3530544
Merge branch 'v2/develop' of github.com:line/lbm-sdk into egon/v2/fea…
May 7, 2021
6437414
chore: base coverage is too low. lower target
May 8, 2021
ad06f51
chore: enable codecov app, modules, client
May 8, 2021
8b630f5
chore: enable codecov patch
May 8, 2021
882318d
chore: use telemetry instead of prometheus
May 10, 2021
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
Prev Previous commit
Next Next commit
feat: add more cache metric; bytes size, entry count
Woosang Son committed May 1, 2021
commit 9e3351d21a32c89c29acce99f3791be26aff724d
5 changes: 4 additions & 1 deletion store/cache/cache.go
Original file line number Diff line number Diff line change
@@ -109,7 +109,10 @@ func (ckv *CommitKVStoreCache) Get(key []byte) []byte {
ckv.metrics.InterBlockCacheMisses.Add(1)
value := ckv.CommitKVStore.Get(key)
ckv.cache.Set(key, value)

stats := fastcache.Stats{}
ckv.cache.UpdateStats(&stats)
ckv.metrics.InterBlockCacheEntries.Set(float64(stats.EntriesCount))
ckv.metrics.InterBlockCacheBytes.Set(float64(stats.BytesSize))
return value
}

25 changes: 20 additions & 5 deletions store/cache/metrics.go
Original file line number Diff line number Diff line change
@@ -15,9 +15,10 @@ const (

// Metrics contains metrics exposed by this package.
type Metrics struct {
// Time between BeginBlock and EndBlock.
InterBlockCacheHits metrics.Counter
InterBlockCacheMisses metrics.Counter
InterBlockCacheHits metrics.Counter
InterBlockCacheMisses metrics.Counter
InterBlockCacheEntries metrics.Gauge
InterBlockCacheBytes metrics.Gauge
}

// PrometheusMetrics returns Metrics build using Prometheus client library.
@@ -41,14 +42,28 @@ func PrometheusMetrics(namespace string, storeName string, labelsAndValues ...st
Name: storeName + "_inter_block_cache_misses",
Help: "Cache misses of the inter block cache",
}, labels).With(labelsAndValues...),
InterBlockCacheEntries: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: storeName + "_inter_block_cache_entries",
Help: "Cache entry count",
}, labels).With(labelsAndValues...),
InterBlockCacheBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace,
Subsystem: MetricsSubsystem,
Name: storeName + "_inter_block_cache_bytes_size",
Help: "Cache bytes size",
}, labels).With(labelsAndValues...),
}
}

// NopMetrics returns no-op Metrics.
func NopMetrics() *Metrics {
return &Metrics{
InterBlockCacheHits: discard.NewCounter(),
InterBlockCacheMisses: discard.NewCounter(),
InterBlockCacheHits: discard.NewCounter(),
InterBlockCacheMisses: discard.NewCounter(),
InterBlockCacheEntries: discard.NewGauge(),
InterBlockCacheBytes: discard.NewGauge(),
}
}