My problem is no matter how I build sqlite - my binary is much slower than the precompiled one on sqlite download page (about 3 - 6 times depending on the query).
I am using sqlite3.h and sqlite3.c from the amalgamation source:
http://www.sqlite.org/sqlite-amalgamation-3070602.zip
I have added the following flags when compiling sqlite:
gcc
-s -O4 -I. -fomit-frame-pointer
-DNDEBUG
-DSQLITE_OS_WIN=1
-DSQLITE_HAVE_READLINE=0
-DSQLITE_THREADSAFE=1
-DSQLITE_TEMP_STORE=2
-DSQLITE_ENABLE_RTREE
-DSQLITE_ENABLE_FTS3
-DSQLITE_OMIT_COMPILEOPTION_DIAGS
-DSQLITE_ENABLE_COLUMN_METADATA
-DNO_TCL
I built it both with MINGW and with MSVS 2010.
Does anyone one know how to build s开发者_运维知识库qlite to get the same binary as on download page ?
Any help would be appreciated.
Follow the guide on SQLite wiki : How to compile and check what are the arguments Make
passes to the compiler. My first suspect would be -O4
, as the highest level GCC understands is -O3
, and even this usually turns out worse than -O2
or -Os
(because small size == no CPU cache misses, and -O3
bloats the binary really badly).
Although I can see the approach differs: Build On Windows Without Tcl uses -O2
, but ticket #931 uses the damned -O4
"Gentoo Ricer Mode". Either way, those optimization switches aren't worth much without specifying target architecture: try -march=core2
or -march=native
for auto-detection, but remember that such code won't work on earlier CPUs. -march=nocona
will work on anything newer than Pentium 4 and still gives the compiler a lot of room for useful optimizations.
精彩评论