Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization problem on FreeBSD #550

Open
sem-hub opened this issue Nov 29, 2024 · 1 comment
Open

Optimization problem on FreeBSD #550

sem-hub opened this issue Nov 29, 2024 · 1 comment

Comments

@sem-hub
Copy link

sem-hub commented Nov 29, 2024

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.

  1. Add a `volatile' keyword. Still different results.
  2. Turn off all optimizations. It will confuse users. Their computers "become slower". But it makes most correct results.
  3. 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.

@renanlecaro
Copy link

renanlecaro commented Dec 17, 2024

I was surprised by the same issue when trying to compare the performance of two workstations, one on freebsd and one on linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants