Public bug reported:

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

** Affects: ubuntu
     Importance: Undecided
         Status: New

-- 
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/+bug/2101201/+subscriptions


-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to