On 12/8/20 1:56 PM, Ilya Maximets wrote: > nbctl always iterates over all ports in all logical switches or routers > to find to which logical router/switch current port belongs. This > could be optimized by iterating only once and caching the current > state. This should improve a little bit performance of this utility > in case where many updates are passed in a single nbctl command. > > However, this change alone will slightly reduce performance of > standalone commands, since we're iterating twice over ports on port > deletion. > > Cache is required for the upcoming change that will make nbctl to use > partial set updates. It will allow us to drop redundant iterations > over ports, i.e. to not duplicate work. > > Signed-off-by: Ilya Maximets <[email protected]> > --- > utilities/ovn-nbctl.c | 209 +++++++++++++++++++++++++++++------------- > 1 file changed, 146 insertions(+), 63 deletions(-) > > diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c > index d19e1b6c6..3886da889 100644 > --- a/utilities/ovn-nbctl.c > +++ b/utilities/ovn-nbctl.c > @@ -125,6 +125,61 @@ static char * OVS_WARN_UNUSED_RESULT main_loop(const > char *args, > const struct timer *); > static void server_loop(struct ovsdb_idl *idl, int argc, char *argv[]); > > +/* A context for keeping track of which switch/router certain ports are > + * connected to. */ > +struct nbctl_context { > + struct ctl_context base; > + struct shash lsp_to_ls; > + struct shash lrp_to_lr;
Hi Ilya, Tiny nit: There are already functions called lsp_to_ls/lrp_to_lr. Not a big deal but it might create a bit of confusion. What about using lsp_to_ls_map/lrp_to_lr_map? The rest looks good to me, therefore: Acked-by: Dumitru Ceara <[email protected]> Thanks, Dumitru _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
