All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iproute2: build nsid-name cache only for commands that need it
@ 2016-09-15  8:23 Anton Aksola
  2016-09-15 13:26 ` Nicolas Dichtel
  0 siblings, 1 reply; 3+ messages in thread
From: Anton Aksola @ 2016-09-15  8:23 UTC (permalink / raw)
  To: netdev

The calling of netns_map_init() before command parsing introduced
a performance issue with large number of namespaces.

As commands such as add, del and exec do not need to iterate through
/var/run/netns it would be good not no build the cache before executing
these commands.

Example:
unpatched:
time seq 1 1000 | xargs -n 1 ip netns add

real    0m16.832s
user    0m1.350s
sys    0m15.029s

patched:
time seq 1 1000 | xargs -n 1 ip netns add

real    0m3.859s
user    0m0.132s
sys    0m3.205s

Signed-off-by: Anton Aksola <aakso@iki.fi>
---
 ip/ipnetns.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index af87065..4546fe7 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -775,8 +775,6 @@ static int netns_monitor(int argc, char **argv)
 
 int do_netns(int argc, char **argv)
 {
-	netns_map_init();
-
 	if (argc < 1)
 		return netns_list(0, NULL);
 
@@ -784,8 +782,10 @@ int do_netns(int argc, char **argv)
 	    (matches(*argv, "lst") == 0))
 		return netns_list(argc-1, argv+1);
 
-	if ((matches(*argv, "list-id") == 0))
+	if ((matches(*argv, "list-id") == 0)) {
+		netns_map_init();
 		return netns_list_id(argc-1, argv+1);
+	}
 
 	if (matches(*argv, "help") == 0)
 		return usage();
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iproute2: build nsid-name cache only for commands that need it
  2016-09-15  8:23 [PATCH] iproute2: build nsid-name cache only for commands that need it Anton Aksola
@ 2016-09-15 13:26 ` Nicolas Dichtel
  2016-09-16  6:27   ` Anton Aksola
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Dichtel @ 2016-09-15 13:26 UTC (permalink / raw)
  To: Anton Aksola, netdev

Le 15/09/2016 à 10:23, Anton Aksola a écrit :
[snip]
> --- a/ip/ipnetns.c
> +++ b/ip/ipnetns.c
> @@ -775,8 +775,6 @@ static int netns_monitor(int argc, char **argv)
>  
>  int do_netns(int argc, char **argv)
>  {
> -	netns_map_init();
> -
>  	if (argc < 1)
>  		return netns_list(0, NULL);
>  
> @@ -784,8 +782,10 @@ int do_netns(int argc, char **argv)
>  	    (matches(*argv, "lst") == 0))
>  		return netns_list(argc-1, argv+1);
>  
> -	if ((matches(*argv, "list-id") == 0))
> +	if ((matches(*argv, "list-id") == 0)) {
> +		netns_map_init();
>  		return netns_list_id(argc-1, argv+1);
> +	}
'ip netns' (ip netns list) also need it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iproute2: build nsid-name cache only for commands that need it
  2016-09-15 13:26 ` Nicolas Dichtel
@ 2016-09-16  6:27   ` Anton Aksola
  0 siblings, 0 replies; 3+ messages in thread
From: Anton Aksola @ 2016-09-16  6:27 UTC (permalink / raw)
  To: Nicolas Dichtel; +Cc: netdev

On Thu, Sep 15, 2016 at 03:26:18PM +0200, Nicolas Dichtel wrote:
[snip]
> 'ip netns' (ip netns list) also need it.

Thanks, I missed your other commit that introduced it. Sending an updated patch.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-16  6:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15  8:23 [PATCH] iproute2: build nsid-name cache only for commands that need it Anton Aksola
2016-09-15 13:26 ` Nicolas Dichtel
2016-09-16  6:27   ` Anton Aksola

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.