On Wed, May 26, 2021 at 10:44:16AM +0800, Tao YunXiang wrote:
> +            /* Use duration as a reference, adjust the value of flow_limit,
> +             * when the duration is short, increase the flow_limit, and vice
> +             * versa. The purpose of using multiple conversions between int
> +             * and float is to make the flow_limit change more linear. */ 
> +
> +            if (duration >= 1000) {
> +                flow_limit = (int) ((float) (flow_limit) / (duration / 
> 1000.0));
> +            } else if (flow_limit * (1000.0 / duration) >= UINT_MAX) {
> +                flow_limit = ofproto_flow_limit;
> +            } else {
> +                flow_limit = (int) (flow_limit * (1000.0 / duration));
>              }

The casts above are pointless.  The cast to float might even be harmful,
since float normally performs worse than double on modern CPUs.  You can
remove all of the casts.

I'm still not sure that I agree with this change, since it seems like it
hasn't been tested very much.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to