RFR: 8310537: Fix -Wconversion warnings in gcUtil.hpp
Axel Boldt-Christmas
aboldtch at openjdk.org
Thu Jun 22 12:32:04 UTC 2023
On Thu, 22 Jun 2023 12:25:53 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:
>> Oh you've had experiences with -Wconversions? Thank you, I can ask you questions. I've tried to fix the interface when possible to be more precise with int types. In this case, it was float so not as sure if this is the right thing to do. I'm not sure I understand your comment. LinearLeastSquare fit seems determined to take double, and AdaptiveWeightedAverage uses float. I'm not sure how to change this to make it safer. My usual strategy would be to make the AdaptiveWeightedAverage take double but then the fall out from that would be more than I can deal with. What do you think?
>
> What I mean is that we are doing a least square fit on a bunch of datapoints. The algorithm requires the mean, sum and sum of squares. If the datapoints truly required double precision or magnitude then storing the sum and sum of square in a double will overflow and/or be inaccurate.
>
> AdaptiveWeightedAverage having a float interface strengthens the case that the samples should be floats, as the running mean should never overflow or underflow the samples `min sample ≤ mean sample ≤ max sample`, (may lose precision, but if the samples are float precision, it seems resonable that the mean also have this precision)
>
> It was not about safety but about having the interface express the capabilities of the class. It can sample float x,y points and provide a least square fit linear function`y(x)`
At least that is my interpretation when I ever see intermediate sums use a type with more bits of information than the samples/parts. But maybe that was never the intent.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14585#discussion_r1238458225
More information about the hotspot-gc-dev
mailing list