You are not logged in.

#1 2017-06-25 17:58:26

johnchen902
Member
Registered: 2016-10-12
Posts: 6

Network Namespace Weird Performance

The performance of network namespace is weird for me.
Consider this script:

#!/usr/bin/env bash
TIMEFORMAT="%R"
sumt1=0
sumt2=0
for ((i=1; i<=10; i++)); do
    echo -ne $i\\r
    sumt1=$(bc <<< "$sumt1 + $(time (unshare -n true) 2>&1)")
    sumt2=$(bc <<< "$sumt2 + $(time (unshare -n true) 2>&1)")
    sleep $(bc <<< "scale=3; ($sumt1 + $sumt2) / $i * 2")
done
echo sumt1 = $sumt1, sumt2 = $sumt2

Run as root, or, if you enabled user namespace, use

unshare -nU

instead.

On my machine, sumt1 is around .02 and sumt2 is around .6
On another machine (not mine), sumt1 is .166 and sumt2 is 31.957 (ran once)

Do you have any clue on this?

Offline

#2 2017-06-25 21:58:54

seth
Member
Registered: 2012-09-03
Posts: 51,056

Re: Network Namespace Weird Performance

Some I/O resp ioctl collision? sum2 runs directly after sum1 which in contrast has padding by the sleep and the echo.
I expect the actual time calls for sum1 will relate to the previous sleep time as well?

Offline

#3 2017-06-25 23:09:55

johnchen902
Member
Registered: 2016-10-12
Posts: 6

Re: Network Namespace Weird Performance

After some user-space timing and reading kernel source code, this is my guess:

When a network namespace is being destroyed, some work is put to the 'netns' worker queue. Subsequent unshare(2) must wait for the work to complete.

Offline

Board footer

Powered by FluxBB