Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
An application performance benchmark has highlighted some differences in memset calls when the same code is run on Ivy Bridge CPU's or Cascade Lake CPU's.
The application is compiled on RHEL-7 on an Ivy Bridge system and then run on RHEL-8 systems equipped with Ivy Bridge and Cascade Lake CPU's.
Here is an example code that will highlight this performance difference:
#include <stdlib.h>
int main(int argc, char * argv[]) {
const int s = atoi(argv[1]) + 0;
int size = s * 1024 * 1024;
char * p;
for(int i = 0; i < s; ++i) {
p = calloc(s, sizeof(int));
}
return 0;
}
This code is compiled on RHEL-7 with the Developer Toolset 8:
source /opt/rh/devtoolset-8/enable
gcc -g test_calloc.c -o test_calloc
valgrind --tool=callgrind --instr-atstart=yes test_calloc 10000
With valgrind one can observe the following:
- Ivy Bridge (Intel(R) Xeon(R) CPU E5-2690 v2) (glibc-2.28)
Total cycle estimation cost: 46 642 220
__memset_sse2_unaligned: 43 799 668
- Cascade Lake (Intel(R) Xeon(R) Gold 6246R) (glibc-2.28)
Total cycle estimation cost: 401 717 850
__memset_avx2_unaligned_erms: 398 874 712
--- edit ---
fixed incorrect values in the valgrind outputs.
I built the test program on an E5-2640 and a 6258R (I couldn't find
exact matches, YMMV). As a sanity check, I did this on both:
$ time ./test_calloc 100000
It took 3.5 seconds on the older cpu and 2.3 seconds on the new one,
which is in line with expectations. Could the customer try this
sanity check?
You noted that the test case was built on RHEL 7. In this particular
test case, this is mostly irrelevent since all the processing happens
within glibc (where calloc and memset live), and on RHEL 8 you'll be
using the RHEL 8 glibc. I assume the customer knows this, but I'm
mentioning it for clarity. RHEL 8 has many optimizations that RHEL 7
doesn't have, so a performance difference is expected. Some of these
optimizations are CPU-specific, so differences between CPU families is
also expected.
If, however, you find that a RHEL 7 test runs faster than a RHEL 8
test on the *same* cpu, we consider that to be a regression.
RHEL 8 does include some ability to tune performance using tunables;
see
https://www.gnu.org/software/libc/manual/html_node/Hardware-Capability-Tunables.html
(note this is for the current upstream, not specifically 2.28; use
"info libc" for documentation specific to your installation, it's in
the Tunables chapter. Important: it's "glibc.tune.*" for 2.28 and
"glibc.cpu.*" for upstream)
You want to play with the glibc.tune.hwcaps tunable, like this
(memset.stap attached):
$ dnf install systemtap-devel
$ stap -c './test_calloc 1000' memset.stap
$ export GLIBC_TUNABLES=glibc.tune.hwcaps=-AVX2_Usable
$ stap -c './test_calloc 1000' memset.stap
Again for clarity - please note also that running an application under
valgrind or one of its related tools (like callgrind) may affect
performance - valgrind is not a benchmark tool, it's a debugging tool.
Perf, likewise, is better for relative performance within an
application, than absolute performance across differing hardware,
since CPU clock speeds and insns/clock may vary. Benchmarking
short-lived functions like memset is difficult, see "Practical
micro-benchmarking with 'ltrace' and 'sched'"[1].
[1] https://developers.redhat.com/blog/2016/03/11/practical-micro-benchmarking-with-ltrace-and-sched
Description of problem: An application performance benchmark has highlighted some differences in memset calls when the same code is run on Ivy Bridge CPU's or Cascade Lake CPU's. The application is compiled on RHEL-7 on an Ivy Bridge system and then run on RHEL-8 systems equipped with Ivy Bridge and Cascade Lake CPU's. Here is an example code that will highlight this performance difference: #include <stdlib.h> int main(int argc, char * argv[]) { const int s = atoi(argv[1]) + 0; int size = s * 1024 * 1024; char * p; for(int i = 0; i < s; ++i) { p = calloc(s, sizeof(int)); } return 0; } This code is compiled on RHEL-7 with the Developer Toolset 8: source /opt/rh/devtoolset-8/enable gcc -g test_calloc.c -o test_calloc valgrind --tool=callgrind --instr-atstart=yes test_calloc 10000 With valgrind one can observe the following: - Ivy Bridge (Intel(R) Xeon(R) CPU E5-2690 v2) (glibc-2.28) Total cycle estimation cost: 46 642 220 __memset_sse2_unaligned: 43 799 668 - Cascade Lake (Intel(R) Xeon(R) Gold 6246R) (glibc-2.28) Total cycle estimation cost: 401 717 850 __memset_avx2_unaligned_erms: 398 874 712 --- edit --- fixed incorrect values in the valgrind outputs.