Skip to content

util/quantile: import quantile library#82146

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
matthewtodd:outliers-quantile
May 31, 2022
Merged

util/quantile: import quantile library#82146
craig[bot] merged 1 commit intocockroachdb:masterfrom
matthewtodd:outliers-quantile

Conversation

@matthewtodd
Copy link
Copy Markdown

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
Copy Markdown
Member

This change is Reviewable

@ajwerner
Copy link
Copy Markdown
Contributor

ajwerner commented May 31, 2022

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

@matthewtodd
Copy link
Copy Markdown
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
Copy Markdown
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

// 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

bors r+

@craig
Copy link
Copy Markdown
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