Compare commits

...

13 Commits

Author SHA1 Message Date
drh a56b14be71 Try to make pcache1TruncateUnsafe() run faster for the case where iLimit is
very close to iMaxKey.

FossilOrigin-Name: 9ab53605d562a926c5620cba9dc96a3b812a432f
2016-08-10 03:35:50 +00:00
drh d4a85406a1 Remove all timers and other debugging logs except for the one timer on
pcache1TruncateUnsafe().

FossilOrigin-Name: 5980e625dbb694dc3b0535e71fd986a6d211e245
2016-08-10 02:54:15 +00:00
drh d59635c402 Add another timer on pcache1TruncateUnsafe().
FossilOrigin-Name: 42ce53f648a506d0a5d9c1231eb28c11b4e6b124
2016-08-09 11:44:06 +00:00
dan 68759c67cb Add a debug timer to pcache1Truncate(). Change the formatting of some other messages to make them easier to read.
FossilOrigin-Name: 7d0af4b53c440f4628f0cecdc40459335630fa4e
2016-08-09 11:23:22 +00:00
drh c2af03b12f Refocus the timer on the pager_end_transaction() routine.
FossilOrigin-Name: 9d4eb6e4750939c48aff267000bd69a73e1dc364
2016-08-09 01:21:16 +00:00
dan a9da72afcd Add extra logging calls to this branch.
FossilOrigin-Name: 491f1ef36e60aa65d71444b604064e3505cabd18
2016-08-04 14:08:06 +00:00
drh f76e89763a A new version of the slow mutex log that uses gettimeofday() instead of
trying to access the hardware timer.

FossilOrigin-Name: 92b9fead353d50eb41f5ab7e3a887dd4e5c3aa80
2016-07-30 03:33:30 +00:00
drh 86815d9aef Turn memory status off by default.
FossilOrigin-Name: ea3c7162dc79cb85868d2bc86d9938fe7c2ae7ef
2016-07-29 16:32:34 +00:00
dan 7544587412 Enhance a debugging log message to better identify a mutex.
FossilOrigin-Name: e60cb6d8852ebf42659c7f2e86a1f6a2492b4664
2016-07-29 14:31:30 +00:00
drh 64a2a7582e Use __sync_synchronous(), when available, instead of a mutex when a memory
barrier is needed.

FossilOrigin-Name: 7d4562e9d577e21406e05300b9a1ad56fded2309
2016-07-29 14:23:23 +00:00
drh c0b9ad1266 Add calls to sqlite3_log() when sqlite3_mutex_enter() takes more than
100,000 CPU cycles.

FossilOrigin-Name: 33c7ef7aca69f9b714bc25b2af5ae2a189d3ba78
2016-07-29 14:10:43 +00:00
dan 5a23b409cb Temporarily add extra sqlite3_log() calls to this version to help with debugging a performance problem.
FossilOrigin-Name: 613c1ceaf4d552dc29aff090825941eaae6baed1
2016-07-16 11:47:45 +00:00
drh 0fb1629f11 Experimental patch restore the slight bias in btree-balancing immediately
after the change to reduces the amount of memcpy() work done by balancing.

FossilOrigin-Name: 46bd9533c0b4656e9fb10eb41c9369ba8a113746
2016-07-14 20:19:24 +00:00
5 changed files with 70 additions and 19 deletions
+9 -9
View File
@@ -1,5 +1,5 @@
C Optimizations\saimed\sat\sreducing\sthe\snumber\sof\smemcpy()\soperations\srequired\sby\sbalance_nonroot().
D 2014-10-27T14:26:54.508
C Try\sto\smake\spcache1TruncateUnsafe()\srun\sfaster\sfor\sthe\scase\swhere\siLimit\sis\nvery\sclose\sto\siMaxKey.
D 2016-08-10T03:35:50.389
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -172,7 +172,7 @@ F src/auth.c d8abcde53426275dab6243b441256fcd8ccbebb2
F src/backup.c a31809c65623cc41849b94d368917f8bb66e6a7e
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
F src/btree.c 9790fb4df51d36861bcbb8cd0a9b41586cbae699
F src/btree.c 44c34502f17681eb957149cc1b8b4e1964ed231a
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
F src/btreeInt.h 026d0129724e8f265fdc60d44ec240cf5a4e6179
F src/build.c 9dc2bd94347b878c89627000c92b0c8d97ec2919
@@ -220,7 +220,7 @@ F src/pager.h d1eee3c3f741be247ce6d82752a178515fc8578b
F src/parse.y 5dfead8aed90cb0c7c1115898ee2266804daff45
F src/pcache.c 4121a0571c18581ee9f82f086d5e2030051ebd6a
F src/pcache.h 9b559127b83f84ff76d735c8262f04853be0c59a
F src/pcache1.c e412cb585f777c840ddce0500eddc5c6043c2bb5
F src/pcache1.c 04279e6cf595ba3520707886e1f4e3a0b6312cad
F src/pragma.c 3f3e959390a10c0131676f0e307acce372777e0f
F src/prepare.c 6ef0cf2f9274982988ed6b7cab1be23147e94196
F src/printf.c 090fac0f779c93c8a95089a125339686648835e4
@@ -232,7 +232,7 @@ F src/shell.c 282f8f5278e0c78eb442217531172ec9e1538796
F src/sqlite.h.in 4a5e5158c189d2bcd45c7c4607c2c0eb6d25c153
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h 17d487c3c91b0b8c584a32fbeb393f6f795eea7d
F src/sqliteInt.h 90519c3b3e8ee90adfce013234c4bd07275d77b5
F src/sqliteInt.h c5d6a3bd2f2514ed08e3b842201b211ad3795d25
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
F src/status.c 961d5926e5a8fda611d385ec22c226b8635cd1cb
F src/table.c 2e99ef7ef16187e17033d9398dc962ce22dab5cb
@@ -1207,7 +1207,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P fc6920b5483eeeb06a474ff399a21afa51dc4859 1f80f8c136ac970dcc7fb2337263dc5922e348c3
R ed2304a6a2e587056109284e9717f063
U dan
Z 986c15e36469a97fa56839a4b2a55b25
P 5980e625dbb694dc3b0535e71fd986a6d211e245
R 2aecde0e663e22b28208114fb4e83a67
U drh
Z 9f57a23eafe4610b0bd9a6ac18d687c6
+1 -1
View File
@@ -1 +1 @@
face33bea1ba3a6d57780655fa827226b4d2baa9
9ab53605d562a926c5620cba9dc96a3b812a432f
+1 -1
View File
@@ -6786,7 +6786,7 @@ static int balance_nonroot(
assert( d<nMaxCells );
assert( r<nMaxCells );
while( szRight==0
|| (!bBulk && szRight+szCell[d]+2<=szLeft-(szCell[r]+2))
|| (!bBulk && szRight+szCell[d]+2<=szLeft-(szCell[r]+(i==k-1?0:2)))
){
szRight += szCell[d] + 2;
szLeft -= szCell[r] + 2;
+37 -7
View File
@@ -498,25 +498,55 @@ static void pcache1TruncateUnsafe(
PCache1 *pCache, /* The cache to truncate */
unsigned int iLimit /* Drop pages with this pgno or larger */
){
TESTONLY( unsigned int nPage = 0; ) /* To assert pCache->nPage is correct */
unsigned int h;
TESTONLY( int nPage = 0; ) /* To assert pCache->nPage is correct */
unsigned int h, iStop;
START_DEBUG_TIMER;
int nFree = 0;
assert( sqlite3_mutex_held(pCache->pGroup->mutex) );
for(h=0; h<pCache->nHash; h++){
PgHdr1 **pp = &pCache->apHash[h];
assert( pCache->iMaxKey >= iLimit );
assert( pCache->nHash > 0 );
if( pCache->iMaxKey - iLimit < pCache->nHash/2 ){
/* If we are just shaving the last few pages off the end of the
** cache, then there is no point in scanning the entire hash table.
** Only scan those hash slots that might contain pages that need to
** be removed. */
iStop = iLimit % pCache->nHash;
h = pCache->iMaxKey % pCache->nHash;
TESTONLY( nPage = -10; ) /* Disable the pCache->nPage validity check */
}else{
/* This is the general case where many pages are being removed.
** It is necessary to scan the entire hash table */
iStop = 0;
h = pCache->nHash - 1;
}
for(;;){
PgHdr1 **pp;
PgHdr1 *pPage;
assert( h<pCache->nHash );
pp = &pCache->apHash[h];
while( (pPage = *pp)!=0 ){
if( pPage->iKey>=iLimit ){
pCache->nPage--;
nFree++;
*pp = pPage->pNext;
if( !pPage->isPinned ) pcache1PinPage(pPage);
pcache1FreePage(pPage);
}else{
pp = &pPage->pNext;
TESTONLY( nPage++; )
TESTONLY( if( nPage>=0 ) nPage++; )
}
}
if( h==iStop ) break;
h = h ? h-1 : pCache->nHash - 1;
}
assert( nPage<0 || pCache->nPage==(unsigned)nPage );
END_DEBUG_TIMER( DEBUG_TIMER_BIG_TIMEOUT ){
sqlite3_log(SQLITE_NOTICE,
"slow pcache1TruncateUnsafe() %lld "
" nFree=%d nHash=%d nPage=%d iLimit=%d iMaxKey=%d",
iDebugTimer,
nFree, pCache->nHash, pCache->nPage, iLimit, pCache->iMaxKey);
}
assert( pCache->nPage==nPage );
}
/******************************************************************************/
@@ -945,7 +975,7 @@ static void pcache1Destroy(sqlite3_pcache *p){
PGroup *pGroup = pCache->pGroup;
assert( pCache->bPurgeable || (pCache->nMax==0 && pCache->nMin==0) );
pcache1EnterMutex(pGroup);
pcache1TruncateUnsafe(pCache, 0);
if( pCache->nPage ) pcache1TruncateUnsafe(pCache, 0);
assert( pGroup->nMaxPage >= pCache->nMax );
pGroup->nMaxPage -= pCache->nMax;
assert( pGroup->nMinPage >= pCache->nMin );
+22 -1
View File
@@ -199,7 +199,7 @@
** be overridden at runtime using the sqlite3_config() API.
*/
#if !defined(SQLITE_DEFAULT_MEMSTATUS)
# define SQLITE_DEFAULT_MEMSTATUS 1
# define SQLITE_DEFAULT_MEMSTATUS 0
#endif
/*
@@ -3815,4 +3815,25 @@ int sqlite3ThreadCreate(SQLiteThread**,void*(*)(void*),void*);
int sqlite3ThreadJoin(SQLiteThread*, void**);
#endif
#include <sys/time.h>
#define START_DEBUG_TIMER \
sqlite3_uint64 iDebugTimerStart, iDebugTimer; \
struct timeval debug_timer_var; \
gettimeofday(&debug_timer_var, 0); \
iDebugTimerStart = 1000000*(sqlite3_uint64)debug_timer_var.tv_sec \
+ debug_timer_var.tv_usec;
#define END_DEBUG_TIMER(nDebugUsec) \
gettimeofday(&debug_timer_var, 0); \
iDebugTimer = 1000000*(sqlite3_uint64)debug_timer_var.tv_sec \
+debug_timer_var.tv_usec-iDebugTimerStart; \
if( iDebugTimer>=nDebugUsec )
#ifndef DEBUG_TIMER_BIG_TIMEOUT
# define DEBUG_TIMER_BIG_TIMEOUT 10000
#endif
#ifndef DEBUG_TIMER_SMALL_TIMEOUT
# define DEBUG_TIMER_SMALL_TIMEOUT 1000
#endif
#endif /* _SQLITEINT_H_ */