[Bug 2101201] [NEW] The performance of the rand() function degradation

2025-03-07 Thread Haixiao Yan
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 s10 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 s10 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 
#include 
#include 
#include 

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 < 200; ++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.

real0m45.613s
user0m45.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

[Bug 2101201] Re: The performance of the rand() function degradation

2025-03-08 Thread Haixiao Yan
** Package changed: ubuntu => glibc (Ubuntu)

-- 
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

[Bug 2101201] Re: The performance of the rand() function degradation

2025-03-10 Thread Haixiao Yan
run 20.04 docker on ubuntu 22.04:

wrlbuild@0ebf1418845d:/mnt/meta-test/recipes-example/example/files$ time 
./mallocrandfree 
Running malloc-rand-free test - creating 1,000 byte buffers 2,000,000 times.

real0m28.753s
user0m28.750s
sys 0m0.002s
wrlbuild@0ebf1418845d:/mnt/meta-test/recipes-example/example/files$ cat 
/etc/issue
Ubuntu 20.04.5 LTS \n \l

ubuntu@haixiao:~/meta-test/recipes-example/example/files$ time ./mallocrandfree 
Running malloc-rand-free test - creating 1,000 byte buffers 2,000,000 times.

real0m46.971s
user0m46.969s
sys 0m0.001s
ubuntu@haixiao:~/meta-test/recipes-example/example/files$ cat /etc/issue
Ubuntu 22.04.4 LTS \n \l

-- 
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

[Bug 2101201] Re: The performance of the rand() function degradation

2025-03-11 Thread Haixiao Yan
ubuntu@haixiao:~$ sudo apport-collect 2101201

Package glibc not installed and no hook available, ignoring

*** Updating problem report

No additional information collected.

Press any key to continue...

No pending crash reports. Try --help for more information.

-- 
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

[Bug 2101201] Re: The performance of the rand() function degradation

2025-03-12 Thread Haixiao Yan
be0cfd848d9ad7378800d6302bc11467cf2b514f fix this issue.

commit be0cfd848d9ad7378800d6302bc11467cf2b514f
Author: Wilco Dijkstra 
Date:   Mon Mar 18 15:18:20 2024 +

stdlib: Add single-threaded fast path to rand()

Improve performance of rand() and __random() by adding a single-threaded
fast path.  Bench-random-lock shows about 5x speedup on Neoverse V1.

Reviewed-by: Adhemerval Zanella  

Pls refer to https://sourceware.org/bugzilla/show_bug.cgi?id=32777

** Bug watch added: Sourceware.org Bugzilla #32777
   https://sourceware.org/bugzilla/show_bug.cgi?id=32777

-- 
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

[Bug 2101201] Re: The performance of the rand() function degradation

2025-03-12 Thread Haixiao Yan
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 s10 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 s10 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 
  #include 
  #include 
  #include 
  
  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 < 200; ++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.
  
  real0m45.613s
  user0m45.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

[Bug 2101201] ProcCpuinfoMinimal.txt

2025-03-12 Thread Haixiao Yan
apport information

** Attachment added: "ProcCpuinfoMinimal.txt"
   
https://bugs.launchpad.net/bugs/2101201/+attachment/5864338/+files/ProcCpuinfoMinimal.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

[Bug 2101201] ProcEnviron.txt

2025-03-12 Thread Haixiao Yan
apport information

** Attachment added: "ProcEnviron.txt"
   
https://bugs.launchpad.net/bugs/2101201/+attachment/5864339/+files/ProcEnviron.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