Skip to content

Commit

Permalink
Enable cache metrics (hypermodeinc#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ibrahim Jarif authored and martinmr committed Oct 25, 2019
1 parent 32a2548 commit 391599f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 2 additions & 6 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ func Open(opt Options) (db *DB, err error) {
NumCounters: int64(float64(opt.MaxCacheSize) * 0.05 * 2),
MaxCost: int64(float64(opt.MaxCacheSize) * 0.95),
BufferItems: 64,
// Enable metrics once https://github.com/dgraph-io/ristretto/issues/92 is resolved.
Metrics: false,
Metrics: true,
}
cache, err := ristretto.NewCache(&config)
if err != nil {
Expand Down Expand Up @@ -385,10 +384,7 @@ func Open(opt Options) (db *DB, err error) {

// CacheMetrics returns the metrics for the underlying cache.
func (db *DB) CacheMetrics() *ristretto.Metrics {
return nil
// Do not enable ristretto metrics in badger until issue
// https://github.com/dgraph-io/ristretto/issues/92 is resolved.
// return db.blockCache.Metrics()
return db.blockCache.Metrics
}

// Close closes a DB. It's crucial to call it to ensure all the pending updates make their way to
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/DataDog/zstd v1.4.1
github.com/cespare/xxhash v1.1.0
github.com/cespare/xxhash/v2 v2.1.0 // indirect
github.com/dgraph-io/ristretto v0.0.0-20191010170704-2ba187ef9534
github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2
github.com/dustin/go-humanize v1.0.0
github.com/golang/protobuf v1.3.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ github.com/dgraph-io/ristretto v0.0.0-20190916120426-cd2835491e0e h1:6ryPDbNhRiZ
github.com/dgraph-io/ristretto v0.0.0-20190916120426-cd2835491e0e/go.mod h1:3dYWm7+Szhwp+wbqGQ5w8o8H1eBkPJEjIEAR5fXCCfs=
github.com/dgraph-io/ristretto v0.0.0-20191010170704-2ba187ef9534 h1:9G6fVccQriMJu4nXwpwLDoy9y31t/KUSLAbPcoBgv+4=
github.com/dgraph-io/ristretto v0.0.0-20191010170704-2ba187ef9534/go.mod h1:edzKIzGvqUCMzhTVWbiTSe75zD9Xxq0GtSBtFmaUTZs=
github.com/dgraph-io/ristretto v0.0.0-20191023190035-3cc39b3d7c56 h1:P9bbRTJ5EM9O9SFJ7an5DJXcR4sIYHOONS0yG5scdb8=
github.com/dgraph-io/ristretto v0.0.0-20191023190035-3cc39b3d7c56/go.mod h1:edzKIzGvqUCMzhTVWbiTSe75zD9Xxq0GtSBtFmaUTZs=
github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e h1:aeUNgwup7PnDOBAD1BOKAqzb/W/NksOj6r3dwKKuqfg=
github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e/go.mod h1:edzKIzGvqUCMzhTVWbiTSe75zD9Xxq0GtSBtFmaUTZs=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
Expand Down

0 comments on commit 391599f

Please sign in to comment.