[ovs-dev] [PATCH v2] ofproto-dpif-upcall: Improve concurrency by adjust flow-limit

Ben Pfaff blp at ovn.org
Thu Jun 10 23:08:16 UTC 2021


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.


More information about the dev mailing list