About a 2.5% speed improvement by reducing the number of sqlite3ThreadData

calls in the parser. (CVS 2924)

FossilOrigin-Name: 0caa1994770142d6ca15284a26bad3879b07b15a
This commit is contained in:
drh 2006-01-12 12:43:36 +00:00
parent f06c59a3e5
commit 4b494d65a7
6 changed files with 24 additions and 18 deletions

View File

@ -1,5 +1,5 @@
C Mark\sthe\send\sof\sthe\sreturn\scodes\sin\sthe\ssqlite3.h.in\stemplate\sfile.\s(CVS\s2923)
D 2006-01-12T02:50:10
C About\sa\s2.5%\sspeed\simprovement\sby\sreducing\sthe\snumber\sof\ssqlite3ThreadData\ncalls\sin\sthe\sparser.\s(CVS\s2924)
D 2006-01-12T12:43:36
F Makefile.in ab3ffd8d469cef4477257169b82810030a6bb967
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -63,14 +63,14 @@ F src/pager.c a96b9c43664670576e41eac699277c7862d604d8
F src/pager.h e0acb095b3ad0bca48f2ab00c87346665643f64f
F src/parse.y 83df51fea35f68f7e07384d75dce83d1ed30434c
F src/pragma.c 4496cc77dc35824e1c978c3d1413b8a5a4c777d3
F src/prepare.c 60c1f5e3d2901d651f8ca9f06e39e2ff3f335844
F src/prepare.c 0f672b97f457a12aa775e46a90e40f71f1b7f680
F src/printf.c f47a2f4b5387cd2ebb12e9117a1a5d6bd9a2b812
F src/random.c d40f8d356cecbd351ccfab6eaedd7ec1b54f5261
F src/select.c 7b19d350cb2a18ae4a59d6b87049aa2ce9c671ae
F src/server.c e425729aa7ff374637033a38ba9fd9938c432244
F src/shell.c 66b073375efbdee19045e7e0cd38b85f9aff71da
F src/sqlite.h.in 492580f7e3ff71eb43193eb7bb98e2d549889ce3
F src/sqliteInt.h adb23b1130eccea72dcc1c617e7045a3e2c774b2
F src/sqliteInt.h 95ece9c9a85bd612c7f56a3dc779d27b867289ab
F src/table.c 486dcfce532685b53b5a2b5da8bba0ded6fb2316
F src/tclsqlite.c d650bea0248fc0a310ddc2cb94273a3a5021fddf
F src/test1.c 30ed0d4d594db0bb2beb98be7024cde1fe686f14
@ -81,7 +81,7 @@ F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 74d91b487c68154156eded457925d96aa2a3fdbb
F src/test7.c c87fd373a613986113717ba51e6a5ad86407c1f7
F src/test_async.c 6776f5027ca6378c116ff5ccc2fe41b908e33772
F src/tokenize.c b75d24cbb419eef9ae7be286dd66723a2ee49f4f
F src/tokenize.c 8b694d42b48f22c2037da7e1e716201aaaaa0f3a
F src/trigger.c 694b247476d2fc0dce003af564f79e8752fc1158
F src/update.c 261d75c702c2852d1a64274d7c414485e6f2d177
F src/utf.c b7bffac4260177ae7f83c01d025fe0f5ed70ce71
@ -91,7 +91,7 @@ F src/vdbe.c 6312ac70c72b84e99d20689a1541648f929ea6a9
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
F src/vdbeInt.h 5451cf71f229e366ac543607c0a17f36e5737ea9
F src/vdbeapi.c afd3837cea0dec93dcb4724d073c84fa0da68e23
F src/vdbeaux.c fca3a799a1e9d5b595a4e5d140f182601258287a
F src/vdbeaux.c b3ac00584f18df9b4ca703ed30f3a378d7a975f7
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c 66e05857c3bd52436161d6bf96a95725f03225a5
F src/where.c a8ba7f4aa2f38166e9f89ecc5dafbdbf41942031
@ -340,7 +340,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P b2dbd1a5b7f5a70049f25755f07b9c4c5116549b
R f01c78cb5101d5f8c4628d8a0f6e1a3c
P 19b848d99f215914454422edc0ce72422de0774e
R 5f224f07433a963a361b7df37917ef79
U drh
Z dd6c0f959f13f7eb30f87b43ed1555a8
Z 4d26681c8651422323c8992b3ad94507

View File

@ -1 +1 @@
19b848d99f215914454422edc0ce72422de0774e
0caa1994770142d6ca15284a26bad3879b07b15a

View File

@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.20 2006/01/11 21:41:22 drh Exp $
** $Id: prepare.c,v 1.21 2006/01/12 12:43:36 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@ -517,9 +517,11 @@ int sqlite3_prepare(
memset(&sParse, 0, sizeof(sParse));
sParse.db = db;
sParse.pTsd = sqlite3ThreadData();
sParse.pTsd->nRef++;
sqlite3RunParser(&sParse, zSql, &zErrMsg);
if( sqlite3ThreadDataReadOnly()->mallocFailed ){
if( sParse.pTsd->mallocFailed ){
sParse.rc = SQLITE_NOMEM;
}
if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
@ -569,12 +571,14 @@ int sqlite3_prepare(
/* We must check for malloc failure last of all, in case malloc() failed
** inside of the sqlite3Error() call above or something.
*/
if( sqlite3ThreadDataReadOnly()->mallocFailed ){
if( sParse.pTsd->mallocFailed ){
rc = SQLITE_NOMEM;
sqlite3Error(db, rc, 0);
}
sParse.pTsd->nRef--;
sqlite3MallocClearFailed();
sqlite3ReleaseThreadData();
return rc;
}

View File

@ -11,7 +11,7 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.464 2006/01/12 01:56:44 drh Exp $
** @(#) $Id: sqliteInt.h,v 1.465 2006/01/12 12:43:36 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
@ -1257,6 +1257,7 @@ struct Parse {
int ckOffset; /* Stack offset to data used by CHECK constraints */
u32 writeMask; /* Start a write transaction on these databases */
u32 cookieMask; /* Bitmask of schema verified databases */
ThreadData *pTsd; /* Thread specific data for this thread */
int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
int cookieValue[MAX_ATTACHED+2]; /* Values of cookies to verify */
#ifndef SQLITE_OMIT_SHARED_CACHE

View File

@ -15,7 +15,7 @@
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.113 2006/01/11 21:41:22 drh Exp $
** $Id: tokenize.c,v 1.114 2006/01/12 12:43:36 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@ -339,6 +339,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
int tokenType;
int lastTokenParsed = -1;
sqlite3 *db = pParse->db;
ThreadData *pTsd = pParse->pTsd;
extern void *sqlite3ParserAlloc(void*(*)(int));
extern void sqlite3ParserFree(void*, void(*)(void*));
extern int sqlite3Parser(void*, int, Token, Parse*);
@ -358,7 +359,7 @@ int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzErrMsg){
assert( pParse->nVarExprAlloc==0 );
assert( pParse->apVarExpr==0 );
pParse->zTail = pParse->zSql = zSql;
while( sqlite3ThreadDataReadOnly()->mallocFailed==0 && zSql[i]!=0 ){
while( pTsd->mallocFailed==0 && zSql[i]!=0 ){
assert( i>=0 );
pParse->sLastToken.z = (u8*)&zSql[i];
assert( pParse->sLastToken.dyn==0 );
@ -406,7 +407,7 @@ abort_parse:
sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
}
sqlite3ParserFree(pEngine, sqlite3FreeX);
if( sqlite3ThreadDataReadOnly()->mallocFailed ){
if( pTsd->mallocFailed ){
pParse->rc = SQLITE_NOMEM;
}
if( pParse->rc!=SQLITE_OK && pParse->rc!=SQLITE_DONE && pParse->zErrMsg==0 ){

View File

@ -102,7 +102,7 @@ int sqlite3VdbeAddOp(Vdbe *p, int op, int p1, int p2){
p->nOp++;
assert( p->magic==VDBE_MAGIC_INIT );
resizeOpArray(p, i+1);
if( sqlite3ThreadDataReadOnly()->mallocFailed ){
if( p->aOp==0 || p->nOp<=i ){
return 0;
}
pOp = &p->aOp[i];