On 3/25/22 16:08, Dumitru Ceara wrote:
> OVS commit 1cc618c32524 ("ovsdb-idl: Fix atomicity of writes that
> don't change a column's value.") [0] explains why writes that don't
> change a column's value cannot be optimized out early if the column is
> read/write.
> 
> In northd, most tables have change tracking enabled, making all their
> columns read/write.  That means that a write to a column (even if it
> doesn't change the value) will add the row to the current transaction.
> Validation is eventually performed before sending the transaction to the
> server but if there are lots of such records this becomes costly.
> 
> Profiling what happens in northd when running with a NB database taken
> from an ovn-k8s-like scale test (16K load balancers applied to 120
> logical switches and routers) we notice that ovn-northd was always
> writing to the SB.Load_Balancer columns even if nothing changed.
> 
> This commit changes that behavior and only writes to the
> SB.Load_Balancer columns if needed.
> 
> Without this change, in our test server, with ovn-northd running
> against NB database mentioned above, processing loop intervals were
> ~13 seconds.
> 
> With this change applied, loop intervals go down to ~7 seconds.
> 
> [0] https://github.com/openvswitch/ovs/commit/1cc618c32524
> 
> Signed-off-by: Dumitru Ceara <[email protected]>
> ---
>  northd/northd.c | 105 ++++++++++++++++++++++++++++++++++++++----------
>  1 file changed, 83 insertions(+), 22 deletions(-)
> 
> diff --git a/northd/northd.c b/northd/northd.c
> index a2cf8d6fc7..f16ca1da63 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -3951,6 +3951,56 @@ build_lb_port_related_data(struct hmap *datapaths, 
> struct hmap *ports,
>      build_lb_svcs(input_data, ovnsb_txn, ports, lbs);
>  }
>  
> +static bool
> +sb_lb_needs_update(const struct ovn_northd_lb *lb,
> +                   const struct sbrec_load_balancer *slb)
> +{
> +    if (strcmp(lb->nlb->name, slb->name)) {
> +        return true;
> +    }
> +
> +    if (!smap_equal(&lb->nlb->vips, &slb->vips)) {
> +        return true;
> +    }
> +
> +    if ((lb->nlb->protocol && !slb->protocol)
> +            || (!lb->nlb->protocol && slb->protocol)) {
> +        return true;
> +    }
> +
> +    if (strcmp(lb->nlb->protocol, slb->protocol)) {

lb->nlb->protocol or slb->protocol can be NULL.

I'll send a v2 to fix this, sorry for the noise!

Thanks,
Dumitru

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to