From: drh Date: Wed, 20 Jan 2016 03:36:32 +0000 (+0000) Subject: Performance improvement in sqlite3DbMallocRaw(). X-Git-Tag: version-3.11.0~118 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=1da26a48ddec0a3dbe8a99464f5171c0cb0354a7;p=thirdparty%2Fsqlite.git Performance improvement in sqlite3DbMallocRaw(). FossilOrigin-Name: ff8eadbed5004ab03438f737492387dee6b9750a --- diff --git a/manifest b/manifest index c246f07bd4..7ce89fb2c7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Suppress\sthe\sdisplay\sof\sthe\sP4\soperand\sin\sEXPLAIN\soutput\swhen\san\sopcode\nhas\sbeen\sconverted\sinto\sa\sNo-op. -D 2016-01-20T02:36:12.461 +C Performance\simprovement\sin\ssqlite3DbMallocRaw(). +D 2016-01-20T03:36:32.428 F Makefile.in a476545d0c8626224d0bacac85c6e2967474af81 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 01e855f958932d0d3ed62ec675fc63e2cef61fcb @@ -311,7 +311,7 @@ F src/journal.c b4124532212b6952f42eb2c12fa3c25701d8ba8d F src/legacy.c ba1863ea58c4c840335a84ec276fc2b25e22bc4e F src/loadext.c 84996d7d70a605597d79c1f1d7b2012a5fd34f2b F src/main.c b686dabe9a7ece9121da87120d5c7bf402d77eb3 -F src/malloc.c 8f787669e79de26efc42272b5797bc00fff527c6 +F src/malloc.c b67c26c359c13836d370350b3f43d228dff5b360 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c 6919bcf12f221868ea066eec27e579fed95ce98b F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 @@ -1419,7 +1419,7 @@ F tool/vdbe_profile.tcl 246d0da094856d72d2c12efec03250d71639d19f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P da527ddae06460ab4b706cdb871de2188ebaf5ac -R 9c350206cbc3ec71bedbf771eaad6af4 +P 9f8297f862a110ded686d091854fae20c6bc393c +R 90386a9e726561832778abc9155cd93d U drh -Z d3ee680a30750cc9b6d539ba48a1436a +Z 2aa4bf87eb3a329408d2351dd05edc2d diff --git a/manifest.uuid b/manifest.uuid index 4615528f3e..50bb5b1795 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f8297f862a110ded686d091854fae20c6bc393c \ No newline at end of file +ff8eadbed5004ab03438f737492387dee6b9750a \ No newline at end of file diff --git a/src/malloc.c b/src/malloc.c index 2c493b9320..c8a04128cf 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -583,8 +583,9 @@ void *sqlite3DbMallocZero(sqlite3 *db, u64 n){ } /* -** Allocate and zero memory. If the allocation fails, make -** the mallocFailed flag in the connection pointer. +** Allocate memory, either lookaside (if possible) or heap. +** If the allocation fails, set the mallocFailed flag in +** the connection pointer. ** ** If db!=0 and db->mallocFailed is true (indicating a prior malloc ** failure on the same database connection) then always return 0. @@ -600,8 +601,8 @@ void *sqlite3DbMallocZero(sqlite3 *db, u64 n){ ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed ** that all prior mallocs (ex: "a") worked too. */ +static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n); void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){ - void *p; assert( db==0 || sqlite3_mutex_held(db->mutex) ); assert( db==0 || db->pnBytesFreed==0 ); #ifndef SQLITE_OMIT_LOOKASIDE @@ -631,7 +632,10 @@ void *sqlite3DbMallocRaw(sqlite3 *db, u64 n){ return 0; } #endif - p = sqlite3Malloc(n); + return dbMallocRawFinish(db, n); +} +static SQLITE_NOINLINE void *dbMallocRawFinish(sqlite3 *db, u64 n){ + void *p = sqlite3Malloc(n); if( !p && db ){ db->mallocFailed = 1; }