From 3c5234430083784b0c5eabba8db7431c27a72505 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 15 Mar 2024 21:50:47 +0100 Subject: [PATCH] out with the -O3, in with the -O2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -O3 does not measurably improve performance of the resulting binaries, neither with lto enabled nor with lto disabled. what it does to however is cause gcc warning spew in libstdc++ that we can't do anything about (and that upon inspection of libstdc++ source looks like a gcc bug). with lto, -O3: Benchmark 1: GC_INITIAL_HEAP_SIZE=10g nix eval --raw --impure --expr 'with import {}; system' Time (mean ± σ): 4.608 s ± 0.027 s [User: 3.866 s, System: 0.522 s] Range (min … max): 4.579 s … 4.640 s 10 runs Benchmark 2: nix eval -f Time (mean ± σ): 408.1 ms ± 25.5 ms [User: 360.0 ms, System: 28.1 ms] Range (min … max): 387.6 ms … 439.0 ms 10 runs with lto, -O2: Benchmark 1: GC_INITIAL_HEAP_SIZE=10g nix eval --raw --impure --expr 'with import {}; system' Time (mean ± σ): 4.632 s ± 0.044 s [User: 3.874 s, System: 0.544 s] Range (min … max): 4.563 s … 4.673 s 10 runs Benchmark 2: nix eval -f Time (mean ± σ): 394.0 ms ± 23.9 ms [User: 351.2 ms, System: 27.6 ms] Range (min … max): 377.8 ms … 429.3 ms 10 runs without lto, -O3: Benchmark 1: GC_INITIAL_HEAP_SIZE=10g nix eval --raw --impure --expr 'with import {}; system' Time (mean ± σ): 4.700 s ± 0.024 s [User: 3.906 s, System: 0.559 s] Range (min … max): 4.663 s … 4.717 s 10 runs Benchmark 2: nix eval -f Time (mean ± σ): 400.4 ms ± 25.6 ms [User: 353.7 ms, System: 26.8 ms] Range (min … max): 379.8 ms … 430.6 ms 10 runs without lto, -O2: Benchmark 1: GC_INITIAL_HEAP_SIZE=10g nix eval --raw --impure --expr 'with import {}; system' Time (mean ± σ): 4.724 s ± 0.030 s [User: 3.924 s, System: 0.570 s] Range (min … max): 4.687 s … 4.749 s 10 runs Benchmark 2: nix eval -f Time (mean ± σ): 392.4 ms ± 24.3 ms [User: 350.9 ms, System: 26.4 ms] Range (min … max): 376.9 ms … 428.0 ms 10 runs fixes #46 Change-Id: Ib8afad8a07c278f57f2e3317d00cce4f9ec0f338 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 87cfc0699..557aa1cc4 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ endif OPTIMIZE = 1 ifeq ($(OPTIMIZE), 1) - GLOBAL_CXXFLAGS += -O3 $(CXXLTO) + GLOBAL_CXXFLAGS += -O2 $(CXXLTO) GLOBAL_LDFLAGS += $(CXXLTO) else GLOBAL_CXXFLAGS += -O0 -U_FORTIFY_SOURCE