Write cache metrcis #378

Merged
fyrchik merged 4 commits from dstepanov-yadro/frostfs-node:feat/write-cache-metrics into master 2023-05-24 10:18:41 +00:00

Metrics added:

  • put, get/head, delete duration & counters. Duration implemented with histogram vector metric labeled with shard id, success flag and storage type. Counters implemented with counter vectors labeled with shard id, success flag and storage type

  • flush and evict counters labeled with shard id, storage type and success flag (for flush only)

  • actual object count in write cache labeled with shard id and storage type

  • estimated cache size (object count x max allowed object size). Estimated size used by put objects.

  • writecache mode metric.

Metrics added: - put, get/head, delete duration & counters. Duration implemented with histogram vector metric labeled with shard id, success flag and storage type. Counters implemented with counter vectors labeled with shard id, success flag and storage type - flush and evict counters labeled with shard id, storage type and success flag (for flush only) - actual object count in write cache labeled with shard id and storage type - estimated cache size (object count x max allowed object size). Estimated size used by put objects. - writecache mode metric.
dstepanov-yadro force-pushed feat/write-cache-metrics from 91f6a694e9 to 914a37b99c 2023-05-19 09:57:56 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 914a37b99c to 8a7ffacf4b 2023-05-19 10:47:06 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 8a7ffacf4b to 4f6e05e208 2023-05-19 11:07:32 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 4f6e05e208 to 9aaaf9a367 2023-05-19 15:23:02 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 9aaaf9a367 to 38f95af11d 2023-05-19 15:51:53 +00:00 Compare
dstepanov-yadro changed title from WIP: Write cache metrcis to Write cache metrcis 2023-05-22 08:03:51 +00:00
dstepanov-yadro requested review from storage-core-committers 2023-05-22 08:04:01 +00:00
dstepanov-yadro requested review from storage-core-developers 2023-05-22 08:04:01 +00:00
acid-ant approved these changes 2023-05-22 08:26:34 +00:00
aarifullin approved these changes 2023-05-22 10:34:11 +00:00
aarifullin left a comment
Collaborator

LGTM

LGTM
ale64bit reviewed 2023-05-23 08:27:02 +00:00
@ -0,0 +32,4 @@
type metricsStub struct{}
func (s *metricsStub) Get(_ time.Duration, _ bool, _ StorageType) {}
Collaborator

you can just delete all placeholders, since none is used, e.g.

func (s *metricsStub) Get(time.Duration, bool, StorageType) {}

Same elsewhere.

you can just delete all placeholders, since none is used, e.g. ``` func (s *metricsStub) Get(time.Duration, bool, StorageType) {} ``` Same elsewhere.
Poster
Collaborator

fixed

fixed
ale64bit marked this conversation as resolved
@ -166,1 +168,4 @@
}
// WithMetrics sets metrics implementation.
func WithMetrics(metrics metrics) Option {
Collaborator

this interface should be exported if it's used as part of the public API of this package?

this interface should be exported if it's used as part of the public API of this package?
Poster
Collaborator

Fixed. I don't think someone will mock it:)

Fixed. I don't think someone will mock it:)
ale64bit marked this conversation as resolved
@ -34,2 +35,4 @@
defer span.End()
startedAt := time.Now()
added := false
Collaborator

hmm, is it really better having these two vars assigned than just calling the c.metrics.Put where they are assigned? Following the flow seems a bit messier this way, IMHO.

hmm, is it really better having these two vars assigned than just calling the `c.metrics.Put` where they are assigned? Following the flow seems a bit messier this way, IMHO.
Poster
Collaborator

It seems to me that it's easier this way: negative case by default, but for success way we need to change vars.

It seems to me that it's easier this way: negative case by default, but for success way we need to change vars.
ale64bit marked this conversation as resolved
@ -33,12 +34,16 @@ func NewNodeMetrics() *NodeMetrics {
})
mustRegister(epoch)
wcMetrcis := newWCMetrics()
Collaborator

s/wcMetrcis/wcMetrics

s/`wcMetrcis`/`wcMetrics`
Poster
Collaborator

fixed

fixed
ale64bit marked this conversation as resolved
@ -0,0 +39,4 @@
modeMetrics map[shardIDMode]metric[prometheus.GaugeFunc]
modeValues map[string]string
modeMtx *sync.RWMutex
Collaborator

no need for pointer

no need for pointer
Poster
Collaborator

fixed

fixed
ale64bit marked this conversation as resolved
@ -0,0 +177,4 @@
mustRegister(m.evictCounter)
}
func setWCDuration(m *metric[*prometheus.HistogramVec], shardID string, success bool, d time.Duration) {
Collaborator

I'm not sure, but do we actually need to pass these (i.e. m) using pointers?

I'm not sure, but do we actually need to pass these (i.e. `m`) using pointers?
Poster
Collaborator

replaced with value pointer

replaced with value pointer
ale64bit marked this conversation as resolved
dstepanov-yadro force-pushed feat/write-cache-metrics from daf63fad63 to d067817895 2023-05-23 09:37:22 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from d067817895 to 9366e26de3 2023-05-23 09:39:45 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 9366e26de3 to ce714c9c89 2023-05-23 09:40:56 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from ce714c9c89 to 180c33a101 2023-05-23 09:43:07 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from 180c33a101 to f3763c1f40 2023-05-23 09:58:35 +00:00 Compare
ale64bit approved these changes 2023-05-23 10:01:31 +00:00
ale64bit reviewed 2023-05-23 10:07:00 +00:00
@ -33,12 +34,16 @@ func NewNodeMetrics() *NodeMetrics {
})
mustRegister(epoch)
wcMetrics := newWCMetrics()
Collaborator

I would personally avoid this sort of abbreviation in type names. writeCacheMetrics is not that long, and autocomplete helps.

I would personally avoid this sort of abbreviation in type names. `writeCacheMetrics` is not that long, and autocomplete helps.
Poster
Collaborator

fixed

fixed
ale64bit marked this conversation as resolved
ale64bit reviewed 2023-05-23 10:09:33 +00:00
@ -0,0 +60,4 @@
}
}
func (m *wcMetrics) WriteCacheGetDurationAdd(shardID string, success bool, d time.Duration) {
Collaborator

eventually we will probably want to think about better structuring this (not specific to this PR). I suspect namespacing the metrics with prefixes in method names won't scale :))

eventually we will probably want to think about better structuring this (not specific to this PR). I suspect namespacing the metrics with prefixes in method names won't scale :))

Maybe we can try it here already? Like nodeMetrics.WriteCache()

Maybe we can try it here already? Like `nodeMetrics.WriteCache()`
Collaborator

if @dstepanov-yadro doesn't mind, that would be ideal.

if @dstepanov-yadro doesn't mind, that would be ideal.
Poster
Collaborator

done

done
ale64bit marked this conversation as resolved
dstepanov-yadro force-pushed feat/write-cache-metrics from f3763c1f40 to 70fa1403f2 2023-05-23 11:28:01 +00:00 Compare
fyrchik reviewed 2023-05-23 13:26:57 +00:00
@ -27,0 +29,4 @@
}
type WriteCacheMetrics interface {
WriteCacheGetDurationAdd(shardID string, success bool, d time.Duration)

We already have AddXDuration pattern for names in this package, why not follow?

We already have `AddXDuration` pattern for names in this package, why not follow?
Poster
Collaborator

fixed

fixed
fyrchik marked this conversation as resolved
@ -241,2 +241,3 @@
// flushObject is used to write object directly to the main storage.
func (c *cache) flushObject(ctx context.Context, obj *object.Object, data []byte) error {
func (c *cache) flushObject(ctx context.Context, obj *object.Object, data []byte, st StorageType) error {
success := true

What about declaring err here instead?

What about declaring `err` here instead?
Poster
Collaborator

done

done
fyrchik marked this conversation as resolved
@ -0,0 +13,4 @@
}
const (
StorageTypeUndefined StorageType = ""

Does it have any specific meaning for the person who views metrics?

Does it have any specific meaning for the person who views metrics?
Poster
Collaborator

This value is used when success = false, so replaced with null value

This value is used when success = false, so replaced with `null` value

Hm, so we can have failed counter increasing both for "any fail" and "fail specific to some storage type"?

Hm, so we can have failed counter increasing both for "any fail" and "fail specific to some storage type"?

I mean may be it's better to have 1 total for everything and specific counters which could increase together with the total one?

I mean may be it's better to have 1 total for everything and specific counters which _could_ increase together with the total one?
Poster
Collaborator

Why it is better?
Now this case can be resolved with selector {success=false}.

Why it is better? Now this case can be resolved with selector {success=false}.
fyrchik marked this conversation as resolved
@ -0,0 +14,4 @@
const (
StorageTypeUndefined StorageType = ""
StorageTypeDB StorageType = "db"

Why are they exported?

Why are they exported?
Poster
Collaborator

they are used in engine pkg

they are used in `engine` pkg
fyrchik marked this conversation as resolved
dstepanov-yadro force-pushed feat/write-cache-metrics from 70fa1403f2 to b438f55e7d 2023-05-23 13:39:18 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from b438f55e7d to a3ecf15929 2023-05-23 13:42:22 +00:00 Compare
dstepanov-yadro force-pushed feat/write-cache-metrics from a3ecf15929 to 639168b74f 2023-05-23 13:52:37 +00:00 Compare
fyrchik approved these changes 2023-05-24 07:56:17 +00:00
dstepanov-yadro force-pushed feat/write-cache-metrics from 639168b74f to c81d44a06d 2023-05-24 08:25:21 +00:00 Compare
fyrchik merged commit a1823423cf into master 2023-05-24 10:18:41 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#378
There is no content yet.