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

Fixes #20607: Make possible to choose precision in compliance percent API #4127

Conversation

fanf
Copy link
Member

@fanf fanf commented Jan 19, 2022

https://issues.rudder.io/issues/20607

Superseed #4115 and keep #4110 for correction of https://issues.rudder.io/issues/20573

The idea is to be able to specify what precision we want for compliance percent in the API calls, and let the backend compute compliance with that value. Most of the pr is passing the precision parameter around.

Note that we can't specify precision value for the lazy val pc attribute in ComplianceLevel instance, so a default value of 2 is kept. That pc value does not seems to be used in the compliance displaying for UI, so it makes me wonder if we really need an heavy lazy val in each ComplianceLevel objects, perhaps we should only compute it when needed with CompliancePercent.fromLevels(c, precision) - cc @ncharles for that.

The 2nd commit totaly remove lazy val from ComplianceLevel object. It will free 3 object alloc by compliance level object, which is not nothing given the number of short lived ones we have, and it seems that there is not many places where they are reused (and where it can't be computed before the different use place).

* (given that we have 14 categories, it means that at worst, if 13 are at 0.1 in place of ~0%;
* the last one will be false by 0.13%, which is ok)
* - always keeps at least 10e(-precision)% for any case
* (given that we have 14 categories, it means that at worst, if 13 are at the mean in place of ~0%;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* (given that we have 14 categories, it means that at worst, if 13 are at the mean in place of ~0%;
* (given that we have 14 categories, it means that at worst, if 13 are at the min in place of ~0%;

type: integer
example: 0
default: 2
description: Number of digits after comma in compliance percent figures
Copy link
Member

Choose a reason for hiding this comment

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

we can maybe precise here that a low value will never be zero and that is it not a simple rounding.

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit c385dca into Normation:branches/rudder/7.0 Jan 19, 2022
@ncharles
Copy link
Member

This is a nice change. I'm indeed not sure of the impact of the lazy val - i did not notice anything significant in my tests - i'm still unsure if we can do better than that or not, but that will be for a next iteration, as perfs are satisfactory

@fanf fanf deleted the bug_20607/make_possible_to_choose_precision_in_compliance_percent_api branch March 15, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants