@@ -37,23 +37,23 @@ For a proper On-CPU analysis, Valkey (and any dynamically loaded library like
3737Valkey Modules) requires stack traces to be available to tracers, which you may
3838need 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
4951It'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