-
Notifications
You must be signed in to change notification settings - Fork 225
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
metric: Add memdb size and key count metric #495
Conversation
f47db59
to
fc7ed92
Compare
Signed-off-by: longfangsong <longfangsong@icloud.com>
4578e55
to
3ead4f6
Compare
@@ -358,6 +361,7 @@ func (db *MemDB) setValue(x memdbNodeAddr, value []byte) { | |||
} | |||
x.vptr = db.vlog.appendValue(x.addr, x.vptr, value) | |||
db.size = db.size - len(oldVal) + len(value) | |||
metrics.MemdbSize.Set(float64(db.size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should Add
be used for the MemdbSize
as it's a server metric?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@longfangsong
PTAL
There could be multiple |
I see, it's for measuring the actual memory consumed by memdb. We can run some experiments with large transactions and compare our metrics with the profiling results to see if it's accurate. |
We don't have a clear idea of the relationship between |
@@ -563,6 +567,8 @@ func (db *MemDB) deleteNode(z memdbNodeAddr) { | |||
|
|||
db.count-- | |||
db.size -= int(z.klen) | |||
metrics.MemdbCount.Dec() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer Set(db.count)
@@ -163,6 +164,8 @@ func (db *MemDB) Reset() { | |||
db.vlogInvalid = false | |||
db.size = 0 | |||
db.count = 0 | |||
metrics.MemdbSize.Set(0.0) | |||
metrics.MemdbCount.Set(0.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't understand it well. The metrics looks like global gauges. May there be many MemDB instances in a single process and they all Set
values to the single gauge by themselves?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've mentioned it above and discussed it with @longfangsong , it's needed to be changed I think.
#520 tracks the memory allocated to the arena. That could be reused here. |
@longfangsong |
I plan to continue this pr after #520 is done. |
@cfzjywxk @MyonKeminta do we want to continue this? |
closing due to inactivity. Please reopen it if need. |
Add size and keys count metric for memdb