Comment 3 for bug 1871240

Revision history for this message
Balint Reczey (rbalint) wrote :

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
#include <time.h>
void main() {
 struct timespec req = {0, 0};
 for (int i = 0; i < 100000; i++){
  clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL);
 }
}
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
user 0m0.226s
sys 0m0.637s
root@ff-glibc:~# apt ^C
root@ff-glibc:~# apt update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [148 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 c-n-f Metadata [265 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [44.4 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [23.6 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 c-n-f Metadata [9136 B]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [1832 B]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [315 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1172 B]
Get:17 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [540 B]
Get:18 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 c-n-f Metadata [116 B]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/main Translation-en [118 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 c-n-f Metadata [7964 B]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [146 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [73.9 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 c-n-f Metadata [4920 B]
Get:24 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [11.6 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [3892 B]
Get:26 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 c-n-f Metadata [480 B]
Get:27 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 c-n-f Metadata [112 B]
Get:28 http://archive.ubuntu.com/ubuntu focal-backports/restricted amd64 c-n-f Metadata [116 B]
Get:29 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [3096 B]
Get:30 http://archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [1448 B]
Get:31 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 c-n-f Metadata [224 B]
Get:32 http://archive.ubuntu.com/ubuntu focal-backports/multiverse amd64 c-n-f Metadata [116 B]
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/scratch2

 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
Hit:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Get:5 http://ppa.launchpad.net/rbalint/scratch2/ubuntu focal InRelease [18.1 kB]
Get:6 http://ppa.launchpad.net/rbalint/scratch2/ubuntu focal/main amd64 Packages [3396 B]
Get:7 http://ppa.launchpad.net/rbalint/scratch2/ubuntu focal/main Translation-en [2076 B]
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