Permalink
Browse files

Switch to optimised builds instead of debug builds

Added a makefile flag (DEBUG) for switching back and forth
Did testing with various optimisation flags and found the fastest
I'm not sure about fast-math yet. It's a bit faster but might make the game unstable.
  • Loading branch information...
TheJosh committed Jul 7, 2014
1 parent 2ca60f6 commit 6733e747678bafd7725f2df2c1fd35b085ffef2d
Showing with 9 additions and 1 deletion.
  1. +9 −1 Makefile
View
@@ -33,12 +33,20 @@ else ifdef EMSCRIPTEN
else
CXX ?= g++
CC ?= gcc
CFLAGS := -DGETOPT -Werror -Wall -ggdb -MMD
CFLAGS := -DGETOPT -Werror -Wall -MMD
LIBS := -lGL -lGLU -L/usr/X11R6/lib -lX11 -lm -lstdc++
PLATFORM := $(OBJPATH)/linux.o
endif
# Debug vs optimised
ifdef DEBUG
CFLAGS := $(CFLAGS) -Og -ggdb
else
CFLAGS := $(CFLAGS) -O2 -ffast-math
endif
# Both Bullet and GLM generate tons of warnings on clang
ifeq ($(CXX),clang)
CFLAGS := $(CFLAGS) -Wno-unknown-warning-option -Wno-overloaded-virtual -Wno-shift-op-parentheses

2 comments on commit 6733e74

@TheJosh

This comment has been minimized.

Show comment
Hide comment
@TheJosh

TheJosh Jul 8, 2014

Owner

I took timings of various compile options:

Before changes (-ggdb):

entities       13227ms   0ms       3ms       959905    0.0138ms  
physics        2779ms    0ms       1ms       959905    0.0029ms  
render         78ms      0ms       1ms       959905    0.0001ms

I tried a number of different options, and ended up choosing -O2 -ffast-math:

entities       9733ms    0ms       1ms       2652474   0.0037ms  
physics        3471ms    0ms       1ms       2652474   0.0013ms  
render         212ms     0ms       1ms       2652474   0.0001ms 
Owner

TheJosh replied Jul 8, 2014

I took timings of various compile options:

Before changes (-ggdb):

entities       13227ms   0ms       3ms       959905    0.0138ms  
physics        2779ms    0ms       1ms       959905    0.0029ms  
render         78ms      0ms       1ms       959905    0.0001ms

I tried a number of different options, and ended up choosing -O2 -ffast-math:

entities       9733ms    0ms       1ms       2652474   0.0037ms  
physics        3471ms    0ms       1ms       2652474   0.0013ms  
render         212ms     0ms       1ms       2652474   0.0001ms 
@TheJosh

This comment has been minimized.

Show comment
Hide comment
@TheJosh

TheJosh Jul 8, 2014

Owner

I also nuked all try/catch and throw statements and compiled with O2 -ffast-math -fno-exceptions, which is apparetly faster on some versions of Android, so I thought it might be faster here too, but it didn't make much difference so I left it as-is:

entities       9564ms    0ms       1ms       2641827   0.0036ms  
physics        3615ms    0ms       42ms      2641827   0.0014ms  
render         244ms     0ms       1ms       2641827   0.0001ms

I tried other things too. -O3 ended up a on par in many cases:

entities       9720ms    0ms       2ms       2669472   0.0036ms  
physics        3729ms    0ms       1ms       2669472   0.0014ms  
render         254ms     0ms       1ms       2669472   0.0001ms

I also tried a clang/llvm build but there is an issue with LuaBridge which meant it's not compiling at the moment.

Owner

TheJosh replied Jul 8, 2014

I also nuked all try/catch and throw statements and compiled with O2 -ffast-math -fno-exceptions, which is apparetly faster on some versions of Android, so I thought it might be faster here too, but it didn't make much difference so I left it as-is:

entities       9564ms    0ms       1ms       2641827   0.0036ms  
physics        3615ms    0ms       42ms      2641827   0.0014ms  
render         244ms     0ms       1ms       2641827   0.0001ms

I tried other things too. -O3 ended up a on par in many cases:

entities       9720ms    0ms       2ms       2669472   0.0036ms  
physics        3729ms    0ms       1ms       2669472   0.0014ms  
render         254ms     0ms       1ms       2669472   0.0001ms

I also tried a clang/llvm build but there is an issue with LuaBridge which meant it's not compiling at the moment.

Please sign in to comment.