Skip to content

Commit 25fe317

Browse files
authored
Updating default make flags for make-settings in profiling section. (#170)
By default, Valkey is now build with `OPTIMIZATION=-O3` and `-fno-omit-frame-pointer`. The make setting in the valkey repository are updated here: https://github.com/valkey-io/valkey/blob/f504cf233bd08d56b1aa4af6c1ef3a2b4aa0ac60/src/Makefile#L32 Docs did not seem to be updated for the same. Updating the docs accordingly. --------- Signed-off-by: Roshan Khatri <[email protected]>
1 parent 1795917 commit 25fe317

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

topics/debugging.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ production environment.
4040

4141
## Compiling Valkey without optimizations
4242

43-
By default Valkey is compiled with the `-O2` switch, this means that compiler
44-
optimizations are enabled. This makes the Valkey executable faster, but at the
45-
same time it makes Valkey (like any other program) harder to inspect using GDB.
43+
By default, Valkey is compiled with the `-O3` optimization flag, which enables
44+
a high level of compiler optimizations that aim to maximize runtime performance.
45+
Valkey is also compiled with the `-fno-omit-frame-pointer` flag by default, ensuring that
46+
the frame pointer is preserved across function calls. This combination allows for
47+
precise stack walking and call stack tracing, which is essential for debugging.
4648

4749
It is better to attach GDB to Valkey compiled without optimizations using the
4850
`make noopt` command (instead of just using the plain `make` command). However,

topics/performance-on-cpu.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ For a proper On-CPU analysis, Valkey (and any dynamically loaded library like
3737
Valkey Modules) requires stack traces to be available to tracers, which you may
3838
need to fix first.
3939

40-
By default, Valkey is compiled with the `-O2` switch (which we intent to keep
41-
during profiling). This means that compiler optimizations are enabled. Many
42-
compilers omit the frame pointer as a runtime optimization (saving a register),
43-
thus breaking frame pointer-based stack walking. This makes the Valkey
44-
executable faster, but at the same time it makes Valkey (like any other program)
45-
harder to trace, potentially wrongfully pinpointing on-CPU time to the last
46-
available frame pointer of a call stack that can get a lot deeper (but
47-
impossible to trace).
40+
By default, Valkey is compiled with the `-O3` optimization flag (which we intent to keep
41+
during profiling). This means that compiler optimizations are enabled which significantly
42+
enhance the performance. Valkey is also compiled with the `-fno-omit-frame-pointer` flag
43+
by default, ensuring that the frame pointer is preserved across function calls.
44+
This combination allows for precise stack walking and call stack tracing,
45+
which is essential for accurate profiling and debugging. Keeping the frame pointer
46+
intact helps profiling tools like `perf`, `gdb`, and others correctly attribute on-CPU
47+
time to deeper call stack frames, leading to more reliable insights into performance bottlenecks
48+
and hotspots. This setup strikes a balance between maintaining a highly optimized executable
49+
and ensuring that profiling and tracing tools provide accurate and actionable data.
4850

4951
It's important that you ensure that:
50-
- debug information is present: compile option `-g`
51-
- frame pointer register is present: `-fno-omit-frame-pointer`
52-
- we still run with optimizations to get an accurate representation of production run times, meaning we will keep: `-O2`
52+
- we still run with optimizations to get an accurate representation of production run times, meaning we will keep: `-O3`
5353

54-
You can do it as follows within redis main repo:
54+
You can do it as follows within valkey main repo:
5555

56-
$ make SERVER_CFLAGS="-g -fno-omit-frame-pointer"
56+
$ make SERVER_CFLAGS="-g"
5757

5858
## A set of instruments to identify performance regressions and/or potential **on-CPU performance** improvements
5959

0 commit comments

Comments
 (0)