[Bug 1797335] Re: strstr() on ubuntu18.04 8 times slower than on ubuntu16
Balint Reczey
1797335 at bugs.launchpad.net
Fri Oct 9 18:10:37 UTC 2020
Verified 2.27-3ubuntu1.3 on Bionic:
root at bb-glibc:~# gcc strstr.c
root at bb-glibc:~# time ./a.out aa
matches = 3000000
real 0m4.149s
user 0m4.146s
sys 0m0.000s
root at bb-glibc:~# sed -i s/backports/proposed/ /etc/apt/sources.list
root at bb-glibc:~# apt update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-proposed InRelease [242 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 Packages [123 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-proposed/main Translation-en [30.1 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic-proposed/restricted amd64 Packages [40.9 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic-proposed/restricted Translation-en [7508 B]
Get:9 http://archive.ubuntu.com/ubuntu bionic-proposed/universe amd64 Packages [22.1 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-proposed/universe Translation-en [11.0 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic-proposed/multiverse amd64 Packages [7244 B]
Get:12 http://archive.ubuntu.com/ubuntu bionic-proposed/multiverse Translation-en [2172 B]
Fetched 664 kB in 1s (852 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
21 packages can be upgraded. Run 'apt list --upgradable' to see them.
root at bb-glibc:~# apt install libc6 libc-bin locales
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfreetype6
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libc-dev-bin libc6-dev
Suggested packages:
glibc-doc
The following packages will be upgraded:
libc-bin libc-dev-bin libc6 libc6-dev locales
5 upgraded, 0 newly installed, 0 to remove and 16 not upgraded.
Need to get 9741 kB of archives.
After this operation, 13.3 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libc6-dev amd64 2.27-3ubuntu1.3 [2586 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libc-dev-bin amd64 2.27-3ubuntu1.3 [71.8 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libc6 amd64 2.27-3ubuntu1.3 [2831 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 locales all 2.27-3ubuntu1.3 [3613 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-proposed/main amd64 libc-bin amd64 2.27-3ubuntu1.3 [639 kB]
Fetched 9741 kB in 2s (5058 kB/s)
Preconfiguring packages ...
(Reading database ... 32938 files and directories currently installed.)
Preparing to unpack .../libc6-dev_2.27-3ubuntu1.3_amd64.deb ...
Unpacking libc6-dev:amd64 (2.27-3ubuntu1.3) over (2.27-3ubuntu1.2) ...
Preparing to unpack .../libc-dev-bin_2.27-3ubuntu1.3_amd64.deb ...
Unpacking libc-dev-bin (2.27-3ubuntu1.3) over (2.27-3ubuntu1.2) ...
Preparing to unpack .../libc6_2.27-3ubuntu1.3_amd64.deb ...
Unpacking libc6:amd64 (2.27-3ubuntu1.3) over (2.27-3ubuntu1.2) ...
Setting up libc6:amd64 (2.27-3ubuntu1.3) ...
(Reading database ... 32938 files and directories currently installed.)
Preparing to unpack .../locales_2.27-3ubuntu1.3_all.deb ...
Unpacking locales (2.27-3ubuntu1.3) over (2.27-3ubuntu1.2) ...
Preparing to unpack .../libc-bin_2.27-3ubuntu1.3_amd64.deb ...
Unpacking libc-bin (2.27-3ubuntu1.3) over (2.27-3ubuntu1.2) ...
Setting up libc-bin (2.27-3ubuntu1.3) ...
Setting up libc-dev-bin (2.27-3ubuntu1.3) ...
Setting up libc6-dev:amd64 (2.27-3ubuntu1.3) ...
Setting up locales (2.27-3ubuntu1.3) ...
Generating locales (this might take a while)...
en_US.UTF-8... done
Generation complete.
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root at bb-glibc:~# apt list --upgradable
Listing... Done
cryptsetup/bionic-proposed 2:2.0.2-1ubuntu1.2 amd64 [upgradable from: 2:2.0.2-1ubuntu1.1]
cryptsetup-bin/bionic-proposed 2:2.0.2-1ubuntu1.2 amd64 [upgradable from: 2:2.0.2-1ubuntu1.1]
libcryptsetup12/bionic-proposed 2:2.0.2-1ubuntu1.2 amd64 [upgradable from: 2:2.0.2-1ubuntu1.1]
libparted2/bionic-proposed 3.2-20ubuntu0.3 amd64 [upgradable from: 3.2-20ubuntu0.2]
linux-libc-dev/bionic-proposed 4.15.0-119.120 amd64 [upgradable from: 4.15.0-118.119]
login/bionic-proposed 1:4.5-1ubuntu2.1 amd64 [upgradable from: 1:4.5-1ubuntu2]
multiarch-support/bionic-proposed 2.27-3ubuntu1.3 amd64 [upgradable from: 2.27-3ubuntu1.2]
openssh-client/bionic-proposed 1:7.6p1-4ubuntu0.4 amd64 [upgradable from: 1:7.6p1-4ubuntu0.3]
openssh-server/bionic-proposed 1:7.6p1-4ubuntu0.4 amd64 [upgradable from: 1:7.6p1-4ubuntu0.3]
openssh-sftp-server/bionic-proposed 1:7.6p1-4ubuntu0.4 amd64 [upgradable from: 1:7.6p1-4ubuntu0.3]
parted/bionic-proposed 3.2-20ubuntu0.3 amd64 [upgradable from: 3.2-20ubuntu0.2]
passwd/bionic-proposed 1:4.5-1ubuntu2.1 amd64 [upgradable from: 1:4.5-1ubuntu2]
python3-distupgrade/bionic-proposed 1:18.04.39 all [upgradable from: 1:18.04.38]
sudo/bionic-proposed 1.8.21p2-3ubuntu1.3 amd64 [upgradable from: 1.8.21p2-3ubuntu1.2]
ubuntu-release-upgrader-core/bionic-proposed 1:18.04.39 all [upgradable from: 1:18.04.38]
uidmap/bionic-proposed 1:4.5-1ubuntu2.1 amd64 [upgradable from: 1:4.5-1ubuntu2]
root at bb-glibc:~# time ./a.out aa
matches = 3000000
real 0m0.410s
user 0m0.407s
sys 0m0.003s
root at bb-glibc:~# cat /proc/cpuinfo | head -n 6
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 60
model name : Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
stepping : 3
root at bb-glibc:~# cat /proc/cpuinfo | head -n 6
** Tags removed: verification-needed verification-needed-bionic
** Tags added: verification-done verification-done-bionic
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1797335
Title:
strstr() on ubuntu18.04 8 times slower than on ubuntu16
Status in GLibC:
Unknown
Status in glibc package in Ubuntu:
Fix Released
Status in glibc source package in Bionic:
Fix Committed
Status in glibc source package in Cosmic:
Won't Fix
Bug description:
[Impact]
* Strstr() from glibc is up to 8 times slower than it was on ubuntu16.
[Test Case]
* Compile and run the attached strstr.c test on an affected Haswell CPU. For the exact Haswell model see the upstream bug report, Qemu can be used to emulate the right model.
* Observe much faster execution times with the fixed glibc package.
[Regression Potential]
* The fix changes the per-model CPU feautures handling in a very
specific way fixing a previous change in the same area. Regressions
here are unlikely, but could in theory cause slowdowns, crashes and
miscalculations if the wrong CPU features are becoming used.
[Original Bug Text]
strstr() from glibc is up to 8 times slower than it was on ubuntu16. Looks like the sse2 optimized code is not used. To reproduce compile attached file (strstr.c) :
$ gcc -o strstr strstr.c
and then run on the 2 platforms :
$ vagrant init ubuntu/bionic64
$ vagrant up
$ vagrant ssh
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-36-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Thu Oct 11 09:02:46 UTC 2018
System load: 0.0 Processes: 97
Usage of /: 9.8% of 9.63GB Users logged in: 0
Memory usage: 12% IP address for enp0s3: 10.0.2.15
Swap usage: 0%
* Security certifications for Ubuntu!
We now have FIPS, STIG, CC and a CIS Benchmark.
- http://bit.ly/Security_Certification
* Want to make a highly secure kiosk, smart display or touchscreen?
Here's a step-by-step tutorial for a rainy weekend, or a startup.
- https://bit.ly/secure-kiosk
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
Last login: Thu Oct 11 09:02:17 2018 from 10.0.2.2
vagrant at ubuntu-bionic:~$ cd /vagrant
vagrant at ubuntu-bionic:/vagrant$ time ./strstr aa
matches = 3000000
real 0m4.877s
user 0m4.852s
sys 0m0.012s
vagrant at ubuntu-bionic:/vagrant$
Same machine :
$ vagrant init ubuntu/xenial64
$ vagrant up
$ vagrant ssh
Welcome to Ubuntu 16.04.5 LTS (GNU/Linux 4.4.0-135-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Thu Oct 11 08:22:26 2018 from 10.0.2.2
vagrant at ubuntu-xenial:~$ cd /vagrant
vagrant at ubuntu-xenial:/vagrant$ time ./strstr aa
matches = 3000000
real 0m0.525s
user 0m0.508s
sys 0m0.000s
vagrant at ubuntu-xenial:/vagrant$
vagrant at ubuntu-xenial:/vagrant$ time ./strstr aa
matches = 3000000
real 0m0.525s
user 0m0.508s
sys 0m0.000s
vagrant at ubuntu-xenial:/vagrant$
To manage notifications about this bug go to:
https://bugs.launchpad.net/glibc/+bug/1797335/+subscriptions
More information about the foundations-bugs
mailing list