Bug 1976267
| Summary: | memset performance differences between Ivy Bridge and Cascade Lake CPU families | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Sebastien Aime <saime> | ||||
| Component: | glibc | Assignee: | DJ Delorie <dj> | ||||
| Status: | CLOSED INSUFFICIENT_DATA | QA Contact: | qe-baseos-tools-bugs | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 8.2 | CC: | ashankar, codonell, dj, fweimer, mnewsome, pfrankli, sipoyare | ||||
| Target Milestone: | beta | Keywords: | Bugfix, Triaged | ||||
| Target Release: | --- | ||||||
| Hardware: | x86_64 | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2021-10-18 07:43:52 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
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 Created attachment 1798738 [details]
memset systemtap probe script
Sorry! It's attached now. |
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.