Remember the size of the Vdbe.aOp[] array in bytes, to avoid unnecessary

calls to sqlite3_msize().

FossilOrigin-Name: 3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc
This commit is contained in:
drh 2016-01-01 16:42:09 +00:00
parent 3c19bb60d1
commit bd57308eef
4 changed files with 14 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Avoid\smisaligned\smemory\sallocations\son\sSparc\sin\ssqlite3VdbeMakeReady().
D 2016-01-01T16:26:22.999
C Remember\sthe\ssize\sof\sthe\sVdbe.aOp[]\sarray\sin\sbytes,\sto\savoid\sunnecessary\ncalls\sto\ssqlite3_msize().
D 2016-01-01T16:42:09.017
F Makefile.in 28bcd6149e050dff35d4dcfd97e890cd387a499d
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc 5fff077fcc46de7714ed6eebb6159a4c00eab751
@ -338,7 +338,7 @@ F src/shell.c 8d152e833c3b79825978deb83175234749c5cdf3
F src/sqlite.h.in 7d87d71b9a4689c51fa092f48f16590ff71558e3
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
F src/sqlite3ext.h dfbe62ffd95b99afe2140d8c35b180d11924072d
F src/sqliteInt.h 92f83ab4612141f95cdd663ea55fa4528f3f8c2a
F src/sqliteInt.h 30f7e8957ed7d244be027be72ded385154c635df
F src/sqliteLimit.h 216557999cb45f2e3578ed53ebefe228d779cb46
F src/status.c 70912d7be68e9e2dbc4010c93d344af61d4c59ba
F src/table.c 51b46b2a62d1b3a959633d593b89bab5e2c9155e
@ -402,7 +402,7 @@ F src/vdbe.c 39d7628bb8eed10a5378adcf97cca6dce7829a8f
F src/vdbe.h efb7a8c1459e31f3ea4377824c6a7e4cb5068637
F src/vdbeInt.h 75c2e82ee3357e9210c06474f8d9bdf12c81105d
F src/vdbeapi.c 020681b943e77766b32ae1cddf86d7831b7374ca
F src/vdbeaux.c 2a25e57e140a3cdef14dc11912c174cf6eb9d5a6
F src/vdbeaux.c 66b546a1da82dfa6e67985ae0442ba5fd9efe0ff
F src/vdbeblob.c fdc4a81605ae7a35ae94a55bd768b66d6be16f15
F src/vdbemem.c fdd1578e47bea61390d472de53c565781d81e045
F src/vdbesort.c a7ec02da4494c59dfd071126dd3726be5a11459d
@ -1406,7 +1406,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 68360cd2211b7ab25dd4ca55a2e82e31f51f2976
R be44c4e5edec4a82a16bfbdbf7214b99
P a304e34675404aee860fcc97fa4ffcc57c014812
R 4471a4984cac341d5421a7094690c1b8
U drh
Z f1917e9fad1e2726446c5b64d14d6919
Z 73de58c32dddcab1338ba5f059ee0a34

View File

@ -1 +1 @@
a304e34675404aee860fcc97fa4ffcc57c014812
3e852804c85a5c9f4c4ffafd55d03af6d19fe5cc

View File

@ -2732,6 +2732,7 @@ struct Parse {
int nSet; /* Number of sets used so far */
int nOnce; /* Number of OP_Once instructions so far */
int nOpAlloc; /* Number of slots allocated for Vdbe.aOp[] */
int szOpAlloc; /* Bytes of memory space allocated for Vdbe.aOp[] */
int iFixedOp; /* Never back out opcodes iFixedOp-1 or earlier */
int ckBase; /* Base register of data during check constraints */
int iSelfTab; /* Table of an index whose exprs are being coded */

View File

@ -35,6 +35,7 @@ Vdbe *sqlite3VdbeCreate(Parse *pParse){
assert( pParse->aLabel==0 );
assert( pParse->nLabel==0 );
assert( pParse->nOpAlloc==0 );
assert( pParse->szOpAlloc==0 );
return p;
}
@ -124,7 +125,8 @@ static int growOpArray(Vdbe *v, int nOp){
assert( nNew>=(p->nOpAlloc+nOp) );
pNew = sqlite3DbRealloc(p->db, v->aOp, nNew*sizeof(Op));
if( pNew ){
p->nOpAlloc = sqlite3DbMallocSize(p->db, pNew)/sizeof(Op);
p->szOpAlloc = sqlite3DbMallocSize(p->db, pNew);
p->nOpAlloc = p->szOpAlloc/sizeof(Op);
v->aOp = pNew;
}
return (pNew ? SQLITE_OK : SQLITE_NOMEM);
@ -1849,8 +1851,8 @@ void sqlite3VdbeMakeReady(
/* Allocate space for memory registers, SQL variables, VDBE cursors and
** an array to marshal SQL function arguments in.
*/
zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */
nFree = sqlite3_msize(p->aOp) - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */
zCsr = ((u8*)p->aOp) + ROUND8(sizeof(Op)*p->nOp); /* Available space */
nFree = pParse->szOpAlloc - ROUND8(sizeof(Op)*p->nOp); /* Size of zCsr */
resolveP2Values(p, &nArg);
p->usesStmtJournal = (u8)(pParse->isMultiWrite && pParse->mayAbort);