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

util/quantile: import quantile library #82146

Merged
merged 1 commit into from
May 31, 2022
Merged

util/quantile: import quantile library #82146

merged 1 commit into from
May 31, 2022

Conversation

matthewtodd
Copy link
Contributor

For upcoming outliers work in #79451, we'll re-use the biased streaming
quantiles implementation underlying the prometheus client library's
summary type.

But in order to monitor and possibly constrain our memory usage, we'll
need a way to measure the size of each quantile.Stream. That
functionality is not available upstream, and contributions are
explicitly not being accepted (and the original upstream, from
bmizerany, lacks further functionality and is similarly inactive), so we
vendor the library here, unmodified from its v1.0.1, in advance of
adding the methods we need.

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner
Copy link
Contributor

ajwerner commented May 31, 2022

consider putting this library in util/outliers as it's generic?

@matthewtodd
Copy link
Contributor Author

consider putting this library in util/outliers as it's generic?

Good idea, moved to util/quantile. (There's nothing outliers-specific here.)

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM mod the suggestion

pkg/util/quantile/stream.go Outdated Show resolved Hide resolved
// See http://www.cs.rutgers.edu/~muthu/bquant.pdf for time, space, and error
// properties.
func NewHighBiased(epsilon float64) *Stream {
ƒ := func(s *stream, r float64) float64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unicode variables, fun!

@ajwerner
Copy link
Contributor

oh, also retitle the PR/commit to be util/quantile

For upcoming outliers work in #79451, we'll re-use the biased streaming
quantiles implementation underlying the prometheus client library's
[summary][1] type.

But in order to monitor and possibly constrain our memory usage, we'll
need a way to measure the size of each `quantile.Stream`. That
functionality is not available upstream, and contributions are
explicitly [not being accepted][2] (and the [original upstream][3], from
bmizerany, lacks further functionality and is similarly inactive), so we
vendor the library here, unmodified from its [v1.0.1][4], in advance of
adding the methods we need.

[1]: https://prometheus.io/docs/practices/histograms/
[2]: beorn7/perks#5 (comment)
[3]: https://github.com/bmizerany/perks
[4]: https://github.com/beorn7/perks/tree/v1.0.1

Release note: None
@matthewtodd matthewtodd changed the title outliers: import quantile library util/quantile: import quantile library May 31, 2022
@matthewtodd
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented May 31, 2022

Build succeeded:

@craig craig bot merged commit 01a68a3 into cockroachdb:master May 31, 2022
@matthewtodd matthewtodd deleted the outliers-quantile branch June 1, 2022 11:44
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 this pull request may close these issues.

3 participants