real 0m6.080s
user 0m0.229s
sys 0m0.614s
root@ff-glibc:~# for i in $(seq 3); do time ./test-nanosleep ; done
real 0m6.456s
user 0m0.145s
sys 0m0.413s
real 0m5.934s
user 0m0.131s
sys 0m0.377s
real 0m5.689s
user 0m0.141s
sys 0m0.273s
root@ff-glibc:~#
root@ff-glibc:~#
root@ff-glibc:~# for i in $(seq 3); do time ./test-nanosleep ; done
^C
real 0m3.682s
user 0m0.142s
sys 0m0.387s
root@ff-glibc:~# for i in $(seq 5); do time ./test-nanosleep ; done
Latest upload to Groovy has the fix.
Testing the backported version does not show notable regression in clock_nanosleep's CPU utilization (on a Lenovo Yoga X1 Gen 2 laptop):
root@ff-glibc:~# cat > test-nanosleep.c nanosleep( CLOCK_REALTIME, 0, &req, NULL);
#include <time.h>
void main() {
struct timespec req = {0, 0};
for (int i = 0; i < 100000; i++){
clock_
}
}
root@ff-glibc:~# gcc test-nanosleep.c -o test-nanosleep
root@ff-glibc:~# time ./test-nanosleep
real 0m6.110s
user 0m0.291s
sys 0m0.567s
root@ff-glibc:~# time ./test-nanosleep
real 0m6.078s
user 0m0.243s
sys 0m0.614s
root@ff-glibc:~# time ./test-nanosleep
real 0m6.095s archive. ubuntu. com/ubuntu focal InRelease archive. ubuntu. com/ubuntu focal-updates InRelease [111 kB] security. ubuntu. com/ubuntu focal-security InRelease [107 kB] archive. ubuntu. com/ubuntu focal-backports InRelease [98.3 kB] archive. ubuntu. com/ubuntu focal/universe amd64 Packages [8628 kB] security. ubuntu. com/ubuntu focal-security/main amd64 Packages [148 kB] archive. ubuntu. com/ubuntu focal/universe Translation-en [5124 kB] archive. ubuntu. com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB] security. ubuntu. com/ubuntu focal-security/ universe amd64 Packages [44.4 kB] archive. ubuntu. com/ubuntu focal/multiverse amd64 Packages [144 kB] archive. ubuntu. com/ubuntu focal/multiverse Translation-en [104 kB] security. ubuntu. com/ubuntu focal-security/ universe Translation-en [23.6 kB] archive. ubuntu. com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B] security. ubuntu. com/ubuntu focal-security/ universe amd64 c-n-f Metadata [1832 B] archive. ubuntu. com/ubuntu focal-updates/main amd64 Packages [315 kB] security. ubuntu. com/ubuntu focal-security/ multiverse amd64 Packages [1172 B] security. ubuntu. com/ubuntu focal-security/ multiverse Translation-en [540 B] security. ubuntu. com/ubuntu focal-security/ multiverse amd64 c-n-f Metadata [116 B] archive. ubuntu. com/ubuntu focal-updates/main Translation-en [118 kB] archive. ubuntu. com/ubuntu focal-updates/main amd64 c-n-f Metadata [7964 B] archive. ubuntu. com/ubuntu focal-updates/ universe amd64 Packages [146 kB] archive. ubuntu. com/ubuntu focal-updates/ universe Translation-en [73.9 kB] archive. ubuntu. com/ubuntu focal-updates/ universe amd64 c-n-f Metadata [4920 B] archive. ubuntu. com/ubuntu focal-updates/ multiverse amd64 Packages [11.6 kB] archive. ubuntu. com/ubuntu focal-updates/ multiverse Translation-en [3892 B] archive. ubuntu. com/ubuntu focal-updates/ multiverse amd64 c-n-f Metadata [480 B] archive. ubuntu. com/ubuntu focal-backports /main amd64 c-n-f Metadata [112 B] archive. ubuntu. com/ubuntu focal-backports /restricted amd64 c-n-f Metadata [116 B] archive. ubuntu. com/ubuntu focal-backports /universe amd64 Packages [3096 B] archive. ubuntu. com/ubuntu focal-backports /universe Translation-en [1448 B] archive. ubuntu. com/ubuntu focal-backports /universe amd64 c-n-f Metadata [224 B] archive. ubuntu. com/ubuntu focal-backports /multiverse amd64 c-n-f Metadata [116 B] scratch2
user 0m0.226s
sys 0m0.637s
root@ff-glibc:~# apt ^C
root@ff-glibc:~# apt update
Hit:1 http://
Get:2 http://
Get:3 http://
Get:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Get:8 http://
Get:9 http://
Get:10 http://
Get:11 http://
Get:12 http://
Get:13 http://
Get:14 http://
Get:15 http://
Get:16 http://
Get:17 http://
Get:18 http://
Get:19 http://
Get:20 http://
Get:21 http://
Get:22 http://
Get:23 http://
Get:24 http://
Get:25 http://
Get:26 http://
Get:27 http://
Get:28 http://
Get:29 http://
Get:30 http://
Get:31 http://
Get:32 http://
Fetched 15.5 MB in 7s (2197 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
root@ff-glibc:~# add-apt-repository ppa:rbalint/
More info: https:/ /launchpad. net/~rbalint/ +archive/ ubuntu/ scratch2
Press [ENTER] to continue or Ctrl-c to cancel adding it.
Hit:1 http:// archive. ubuntu. com/ubuntu focal InRelease archive. ubuntu. com/ubuntu focal-updates InRelease archive. ubuntu. com/ubuntu focal-backports InRelease security. ubuntu. com/ubuntu focal-security InRelease ppa.launchpad. net/rbalint/ scratch2/ ubuntu focal InRelease [18.1 kB] ppa.launchpad. net/rbalint/ scratch2/ ubuntu focal/main amd64 Packages [3396 B] ppa.launchpad. net/rbalint/ scratch2/ ubuntu focal/main Translation-en [2076 B]
Hit:2 http://
Hit:3 http://
Hit:4 http://
Get:5 http://
Get:6 http://
Get:7 http://
Fetched 23.5 kB in 1s (15.9 kB/s)
Reading package lists... Done
root@ff-glibc:~# time ./test-nanosleep
real 0m6.080s
user 0m0.229s
sys 0m0.614s
root@ff-glibc:~# for i in $(seq 3); do time ./test-nanosleep ; done
real 0m6.456s
user 0m0.145s
sys 0m0.413s
real 0m5.934s
user 0m0.131s
sys 0m0.377s
real 0m5.689s
user 0m0.141s
sys 0m0.273s
root@ff-glibc:~#
root@ff-glibc:~#
root@ff-glibc:~# for i in $(seq 3); do time ./test-nanosleep ; done
^C
real 0m3.682s
user 0m0.142s
sys 0m0.387s
root@ff-glibc:~# for i in $(seq 5); do time ./test-nanosleep ; done
real 0m6.091s
user 0m0.281s
sys 0m0.596s
real 0m6.059s
user 0m0.245s
sys 0m0.599s
real 0m6.066s
user 0m0.226s
sys 0m0.581s
real 0m6.065s
user 0m0.284s
sys 0m0.574s
real 0m6.101s
user 0m0.287s
sys 0m0.587s