apport information ** Tags added: apport-collected jammy
** Description changed: The performance of the rand() function on Ubuntu 22.04 has decreased by 62% compared to Ubuntu 21.04. Measured on Ubuntu 21.04: 28.070s Measured on Ubuntu 22.04: 45.493s Ubuntu 22.04: root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# hyperfine ./mallocrandfree Benchmark 1: ./mallocrandfree Time (mean ± σ): 45.493 s ± 0.229 s [User: 45.489 s, System: 0.001 s] Range (min … max): 45.246 s … 45.858 s 10 runs root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# uname -a Linux ubuntu 6.5.0-18-generic #18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 11:40:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# gcc --version gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# ldd --version ldd (Ubuntu GLIBC 2.35-0ubuntu3.6) 2.35 Copyright (C) 2022 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper. Ubuntu 21.04: root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# hyperfine ./mallocrandfree Benchmark 1: ./mallocrandfree Time (mean ± σ): 28.070 s ± 0.162 s [User: 28.069 s, System: 0.001 s] Range (min … max): 27.772 s … 28.362 s 10 runs root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# uname -a Linux ubuntu 5.11.0-16-generic #17-Ubuntu SMP Wed Apr 14 20:12:43 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# ldd --version ldd (Ubuntu GLIBC 2.33-0ubuntu5) 2.33 Copyright (C) 2021 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Roland McGrath and Ulrich Drepper. root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# gcc --version gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Here is the test code. #cat mallocrandfree.c #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h> void init() { // Tell the user what we are doing. printf("Running malloc-rand-free test - creating 1,000 byte buffers 2,000,000 times.\n"); fflush(stdout); // Seed the random number generator with the current time. srand(time(NULL)); } void loop() { for (int i = 0; i < 2000000; ++i) { //char* bufferPtr = malloc(1000); char bufferPtr[1000]; for (int j = 0; j < 1000; ++j) { bufferPtr[j] = rand() % 256; //bufferPtr[j] = j; } //free(bufferPtr); } } void cleanup() { exit(0); } int main() { init(); loop(); cleanup(); } Also can measured with time: root@ubuntu:/home/ubuntu/meta-test/recipes-example/example/files# time ./mallocrandfree Running malloc-rand-free test - creating 1,000 byte buffers 2,000,000 times. real 0m45.613s user 0m45.602s sys 0m0.008s + --- + ProblemType: Bug + ApportVersion: 2.20.11-0ubuntu82.5 + Architecture: amd64 + CasperMD5CheckResult: pass + DistroRelease: Ubuntu 22.04 + InstallationDate: Installed on 2025-03-07 (5 days ago) + InstallationMedia: Ubuntu 22.04.4 LTS "Jammy Jellyfish" - Release amd64 (20240220) + Package: libc6 2.35-0ubuntu3.9 + PackageArchitecture: amd64 + ProcVersionSignature: Ubuntu 6.8.0-52.53~22.04.1-generic 6.8.12 + RebootRequiredPkgs: Error: path contained symlinks. + Tags: jammy + Uname: Linux 6.8.0-52-generic x86_64 + UpgradeStatus: No upgrade log present (probably fresh install) + UserGroups: docker sudo + _MarkForUpload: True ** Attachment added: "Dependencies.txt" https://bugs.launchpad.net/bugs/2101201/+attachment/5864337/+files/Dependencies.txt -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2101201 Title: The performance of the rand() function degradation To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/2101201/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs