From: drh Date: Sat, 7 Jan 2017 00:42:57 +0000 (+0000) Subject: This hack illustrates how to use the VDBE_PROFILE mechanism to show which X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=708991af38f21741c306f87a71d12e893d34dbb1;p=thirdparty%2Fsqlite.git This hack illustrates how to use the VDBE_PROFILE mechanism to show which bytecode operators are using resources other than time. In this case, the number of loops through the binary search code in sqlite3BtreeMovetoUnpacked() is measured, for the purpose of helping to identify unnecessary btree searches. FossilOrigin-Name: 746b1836834914627d97369690b9596d80235a35 --- diff --git a/manifest b/manifest index 67b3b622ee..57ac852545 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\s"PRAGMA\scase_sensitive_like"\sand\s"PRAGMA\sshrink_memory"\sset\sthe\nnumber\sof\soutput\scolumns\sto\s0\s(as\sthey\sare\sstatements\sthat\sreturn\sno\sdata). -D 2017-01-06T13:49:40.112 +C This\shack\sillustrates\show\sto\suse\sthe\sVDBE_PROFILE\smechanism\sto\sshow\swhich\nbytecode\soperators\sare\susing\sresources\sother\sthan\stime.\s\sIn\sthis\scase,\sthe\nnumber\sof\sloops\sthrough\sthe\sbinary\ssearch\scode\sin\ssqlite3BtreeMovetoUnpacked()\nis\smeasured,\sfor\sthe\spurpose\sof\shelping\sto\sidentify\sunnecessary\sbtree\ssearches. +D 2017-01-07T00:42:57.449 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -331,7 +331,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c d2c100618784bd89c089fcef03ff6e789768ecae +F src/btree.c 616212acc17a89d835fb5a9d379881af42485790 F src/btree.h 2349a588abcd7e0c04f984e15c5c777b61637583 F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af @@ -393,7 +393,7 @@ F src/shell.c 6095531aa900decdaa765e0f3993fba7153c92c1 F src/sqlite.h.in 29bda4bee01248a5650567d7a22fac39bad1b542 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 8648034aa702469afb553231677306cc6492a1ae -F src/sqliteInt.h 9fdfb8789b27a621f3401468bc1705c32308f877 +F src/sqliteInt.h 44a74e425b9e4a88b15e3ece325a0c03f74ce715 F src/sqliteLimit.h c0373387c287c8d0932510b5547ecde31b5da247 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c 5226df15ab9179b9ed558d89575ea0ce37b03fc9 @@ -455,7 +455,7 @@ F src/update.c 1da7c462110bffed442a42884cb0d528c1db46d8 F src/utf.c 699001c79f28e48e9bcdf8a463da029ea660540c F src/util.c a88b0466fddf445ce752226d4698ca3faada620a F src/vacuum.c 33c174b28886b2faf26e503b5a49a1c01a9b1c16 -F src/vdbe.c 88bd6c32b333580d2661ac3afe33369757fb1522 +F src/vdbe.c 2d97b1955677d059ed0fbb70edbd6caa356a827d F src/vdbe.h b0866e4191f096f1c987a84b042c3599bdf5423b F src/vdbeInt.h 281cb70332dc8b593b8c7afe776f3a2ba7d4255e F src/vdbeapi.c d6ebaa465f070eb1af8ba4e7b34583ece87bdd24 @@ -1543,7 +1543,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 609ac1c73f7c2b48a571c178a72383996a9538fe -R 812971df62a9791f0bfb0122470a2213 -U dan -Z ebefd6b7654323e8a23a6cf648753c0a +P 6696cd1878be4bd44a24841b04163e52d847711e +R 84e708f4e891dde33f19bfdca19817dd +T *branch * vdbe-aux-perf +T *sym-vdbe-aux-perf * +T -sym-trunk * +U drh +Z de29ad8a6d413bf4c57cf80372a53ca1 diff --git a/manifest.uuid b/manifest.uuid index 865cc47649..4386b3c190 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6696cd1878be4bd44a24841b04163e52d847711e \ No newline at end of file +746b1836834914627d97369690b9596d80235a35 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index f869761625..f9c33c95ef 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5124,6 +5124,7 @@ int sqlite3BtreeMovetoUnpacked( Pgno chldPg; MemPage *pPage = pCur->apPage[pCur->iPage]; u8 *pCell; /* Pointer to current cell in pPage */ +sqlite3PerfCnt++; /* pPage->nCell must be greater than zero. If this is the root-page ** the cursor would have been INVALID above and this for(;;) loop diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 8cfa0f88f7..efd5ff7e2e 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4321,4 +4321,6 @@ Expr *sqlite3VectorFieldSubexpr(Expr*, int); Expr *sqlite3ExprForVectorField(Parse*,Expr*,int); void sqlite3VectorErrorMsg(Parse*, Expr*); +sqlite3_uint64 sqlite3PerfCnt; + #endif /* SQLITEINT_H */ diff --git a/src/vdbe.c b/src/vdbe.c index 5e707a6232..02444bb356 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -506,7 +506,8 @@ static void registerTrace(int iReg, Mem *p){ ** hwtime.h contains inline assembler code for implementing ** high-performance timing routines. */ -#include "hwtime.h" +/*#include "hwtime.h"*/ +#define sqlite3Hwtime(x) sqlite3PerfCnt #endif