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

benchmark batch Metric Vector #72

Closed
siddontang opened this issue Sep 24, 2016 · 2 comments
Closed

benchmark batch Metric Vector #72

siddontang opened this issue Sep 24, 2016 · 2 comments
Assignees

Comments

@siddontang
Copy link
Contributor

If we want to inc some VecMetric many times, we may first cache in a map then inc in batch.

let m = HashMap::new();
m["a"] += 1
m["b"] += 1
// many times

for (key, value) in &m {
    metric.with_label_values(&[key]).add(value);
}

to compare with

 metric.with_label_values(&["a"]).inc(1);
 metric.with_label_values(&["b"]).inc(1);
// many times 
@overvenus
Copy link
Member

I prefer the second one.

Benchmark results are not accurate, if we cache things in a hashmap, because hashmap is relatively slow in Rust.

@siddontang
Copy link
Contributor Author

Sometimes we can't call the metric too frequently, so we should cache it and call the metric in batch.
Is HashMap really slow for the above case?
Or we can use BTreeMap or even define a structure for the multi metrics.
What I want here is to supply a optimization guide for user when they find metrics reduce the performance.

Btw, Benchmark may be not accurate, but it can still show something for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants