From 3469c6509c4078f6b2738359ebaacf5df707a6a1 Mon Sep 17 00:00:00 2001 From: Maria Markova Date: Sun, 2 Oct 2022 14:15:14 +0200 Subject: [PATCH] Change compiler optimizations to -O3 -flto (#11207) Optimization update from -O2 to -O3 -flto gives up to 5% performance gain in 'redis-benchmarks-spec-client-runner' tests geomean where GCC 9.4.0 is used for build * Fix for false-positive warning in bitops.c Warning appeared with O3, on CentOS during inlininig procedure * Fixed unitialized streamID within streamTrim() (#1) Co-authored-by: filipe oliveira --- src/Makefile | 2 +- src/bitops.c | 4 +++- src/t_stream.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index fdfef2b3c..6a56c1dff 100644 --- a/src/Makefile +++ b/src/Makefile @@ -15,7 +15,7 @@ release_hdr := $(shell sh -c './mkreleasehdr.sh') uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') -OPTIMIZATION?=-O2 +OPTIMIZATION?=-O3 -flto DEPENDENCY_TARGETS=hiredis linenoise lua hdr_histogram NODEPS:=clean distclean diff --git a/src/bitops.c b/src/bitops.c index e35001937..23d80554e 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -1180,7 +1180,9 @@ void bitfieldGeneric(client *c, int flags) { addReplyNull(c); } } else { - uint64_t oldval, newval, wrapped, retval; + /* Initialization of 'wrapped' is required to avoid + * false-positive warning "-Wmaybe-uninitialized" */ + uint64_t oldval, newval, retval, wrapped = 0; int overflow; oldval = getUnsignedBitfield(o->ptr,thisop->offset, diff --git a/src/t_stream.c b/src/t_stream.c index 65a9b5899..454d10b9c 100644 --- a/src/t_stream.c +++ b/src/t_stream.c @@ -747,7 +747,7 @@ int64_t streamTrim(stream *s, streamAddTrimArgs *args) { streamDecodeID(ri.key, &master_id); /* Read last ID. */ - streamID last_id; + streamID last_id = {0,0}; lpGetEdgeStreamID(lp, 0, &master_id, &last_id); /* We can remove the entire node id its last ID < 'id' */