-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
I digged into invistigation why CPU test results on FreeBSD completely mess. `sysbench cpu run' shows millions events per second on FreeBSD and only 1200 on Linux on the same computer.
FreeBSD use this for compile:
sysbench version : 1.0.20-33d3fd27d
CC : cc
CFLAGS : -O2 -funroll-loops -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -Wall -Wextra -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wnested-externs -Wno-format-zero-length -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wcast-align -Wvla -D_THREAD_SAFE -pthread
CPPFLAGS : -D_GNU_SOURCE -I/usr/local/include -I$(top_srcdir)/src -I/usr/local/include/luajit-2.1 -D__x86_64__ -I/usr/local/include
LDFLAGS : -fstack-protector-strong -L/usr/local/lib
LIBS : -lm
EXTRA_LDFLAGS : -lumem
I'v just understand a problem when saw this: `warning: variable 'n' set but not used [-Wunused-but-set-variable]' in tests/cpu/sb_cpu.c. Clang cuts off the loop on optimization. So sysbench compiled with empty cpu test.
I tried to fix it to add volatile' keyword in n` variable definition. Results of CPU test became more resonable but still twice more then in Linux. I've got ~2600 events per second on FreeBSD and ~1200 on Linux (the same machine). So it's not completely solved. Clang and Gcc have very different optimization algorithms.
I played with optimization flags and only -O0 made very close results (about 960 events per second). But it differs from first Linux result: about 1200 event per second.
So, I don't know what is correct way to solve it.
- Add a `volatile' keyword. Still different results.
- Turn off all optimizations. It will confuse users. Their computers "become slower". But it makes most correct results.
- Use Gcc for FreeBSD build (USE_GCC=yes in FreeBSD port Makefile). It's less harmfull decision.
I would prefer third option. It means you should do nothing with sources but FreeBSD maintainers should do. And it's an useless report for you. But I want you know about this problem. If Gcc changed its optimizations, sysbench could be change tests results too.