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

Use []float64 for histogram boundaries, not []metric.Number #758

Merged
merged 9 commits into from
May 21, 2020

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented May 21, 2020

Reading through the histogram aggregator was confusing because the boundaries are specified as []metric.Number, but despite this were expected to be floating point numbers. This makes the boundaries []float, which is less confusing.

This also adds a benchmark. I considered whether binary search outperforms linear search in any practical-sized histogram, and the answer is no. Binary search beats linear search for histograms sized >= 256 to 512 elements.

Resolves #534.
Resolves #759.

@jmacd jmacd added the area:metrics Part of OpenTelemetry Metrics label May 21, 2020
@jmacd jmacd added this to the Beta v0.6 milestone May 21, 2020
@jmacd
Copy link
Contributor Author

jmacd commented May 21, 2020

CURRENT:

BenchmarkHistogramSearchFloat64_1-8      	46579974	        25.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_8-8      	49497470	        31.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_16-8     	36765841	        32.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_32-8     	32826470	        34.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_64-8     	28035928	        40.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_128-8    	22074931	        54.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_256-8    	14861863	        82.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_512-8    	 8601362	       132 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_1024-8   	 5037547	       244 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_1-8        	53172440	        23.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_8-8        	45193213	        28.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_16-8       	39541150	        29.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_32-8       	36276222	        33.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_64-8       	29840234	        36.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_128-8      	22053164	        51.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_256-8      	15829436	        77.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_512-8      	 9319368	       129 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_1024-8     	 5245293	       242 ns/op	       0 B/op	       0 allocs/op

WITH BINARY SEARCH:

BenchmarkHistogramSearchFloat64_1-8      	39085161	        26.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_8-8      	29167771	        42.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_16-8     	22880655	        48.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_32-8     	20022715	        58.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_64-8     	16920318	        67.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_128-8    	15097021	        78.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_256-8    	13093621	        90.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_512-8    	11439160	       108 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchFloat64_1024-8   	 9849621	       121 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_1-8        	43069017	        29.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_8-8        	29564926	        45.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_16-8       	23641772	        61.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_32-8       	19429113	        65.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_64-8       	16292440	        72.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_128-8      	14794202	        81.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_256-8      	12253422	        94.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_512-8      	10108302	       118 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramSearchInt64_1024-8     	 9784033	       125 ns/op	       0 B/op	       0 allocs/op

Copy link
Contributor

@MrAlias MrAlias left a comment

Choose a reason for hiding this comment

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

🚀

@MrAlias MrAlias merged commit 51e5719 into open-telemetry:master May 21, 2020
@jmacd jmacd deleted the jmacd/hist_search branch June 8, 2020 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metrics Part of OpenTelemetry Metrics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use []float64 boundaries for all histograms Consider binary search in Histogram aggregator
4 participants