nickva commented on issue #4650: URL: https://github.com/apache/couchdb/issues/4650#issuecomment-1598153323
Going by https://github.com/open-telemetry/oteps/blob/main/text/0149-exponential-histogram.md and https://opentelemetry.io/blog/2022/exponential-histograms/ it seems exponential base 2 histograms are popular. The scheme to replace Folsom sliding window histogram could be based on persistent terms and counters. ``` persistent_term:put(Histogram, counters:new(1024, [write_concurrency])). ``` ``` Ref = persistent_term:get(histogram_now(Histogram, NowSec)), counters:add(Ref, bucket(Value), Value), ``` bucket index can be computed with a simple hack of starting with a simple float representation: ``` exp(N) when is_integer(N) -> exp(float(N)); exp(F) when is_float(F), F < 0.0 -> 0; exp(F) when is_float(F) -> <<0:1,Exp:11,Mantissa:52>> = <<F:64/float>>, Exp. ``` Exponent then can be scaled by a precision value by shifting left (`bsl 4`, for instance) and combining with the most significant bits of the mantissa (aka the significand). `Index = (Exp bsl 4) bor (Mantissa bsr (52-4))`. The temporal (windowing) aspect can be implementing by having 15 or so counter arrays and writing to the `NowSec % 15`th one. We'll need a similar auto-cleanup / trim process to recycle and clean old entries. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
