1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-10 01:02:56 +03:00

Improved performance by manually in-lining the sqlite3VdbeIdxKeyCompare()

routine for the OP_IdxGT opcode and its kin.

FossilOrigin-Name: 2206a2c848a122ee220c89427f9be0460cba0706f58852139d7b37184ce29a29
This commit is contained in:
drh
2020-09-29 16:05:09 +00:00
parent 46f0f4e56d
commit c40076a8cf
3 changed files with 33 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
C Typo\sfix\sto\srepair\sthe\searly-out\soptimization.\s\sAlso\savoid\sunnecessary\nOP_SeekHit\sopcodes.
D 2020-09-29T15:32:54.786
C Improved\sperformance\sby\smanually\sin-lining\sthe\ssqlite3VdbeIdxKeyCompare()\nroutine\sfor\sthe\sOP_IdxGT\sopcode\sand\sits\skin.
D 2020-09-29T16:05:09.270
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -607,7 +607,7 @@ F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78
F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0
F src/util.c c0c7977de7ef9b8cb10f6c85f2d0557889a658f817b0455909a49179ba4c8002
F src/vacuum.c 492422c1463c076473bae1858799c7a0a5fe87a133d1223239447c422cd26286
F src/vdbe.c f13b70fa1deea20698e19c86c4aae3cf93495c74b4c57e7139f628cf4f711ddf
F src/vdbe.c 72fa5727e874b51f24b72ef12dfec8738e724b4c70c308f1e9fc3b955375f214
F src/vdbe.h 83603854bfa5851af601fc0947671eb260f4363e62e960e8a994fb9bbcd2aaa1
F src/vdbeInt.h 3ca5e9fd6e095a8b6cf6bc3587a46fc93499503b2fe48951e1034ba9e2ce2f6e
F src/vdbeapi.c c5e7cb2ab89a24d7f723e87b508f21bfb1359a04db5277d8a99fd1e015c12eb9
@@ -1880,7 +1880,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P f3c36b840c9a29c0add28039db216f4207a308e5057fc76e3f0004024a8267ac
R b45e4e5d13e7104361979e961b4ebdf2
P 8fd7d8dfcd515aa6b65d6eb27b033d3b3a31db467b9100cc13c62bc60113019e
R 4899ba483a1f0c89bb1918b365591512
U drh
Z 6ed8ad20e25361c120133ce9ede87a2a
Z ee02d60aca1d7fbfb9e679e7d8012083

View File

@@ -1 +1 @@
8fd7d8dfcd515aa6b65d6eb27b033d3b3a31db467b9100cc13c62bc60113019e
2206a2c848a122ee220c89427f9be0460cba0706f58852139d7b37184ce29a29

View File

@@ -6026,8 +6026,31 @@ case OP_IdxGE: { /* jump */
}
}
#endif
res = 0; /* Not needed. Only used to silence a warning. */
rc = sqlite3VdbeIdxKeyCompare(db, pC, &r, &res);
/* Inlined version of sqlite3VdbeIdxKeyCompare() */
{
i64 nCellKey = 0;
BtCursor *pCur;
Mem m;
assert( pC->eCurType==CURTYPE_BTREE );
pCur = pC->uc.pCursor;
assert( sqlite3BtreeCursorIsValid(pCur) );
nCellKey = sqlite3BtreePayloadSize(pCur);
/* nCellKey will always be between 0 and 0xffffffff because of the way
** that btreeParseCellPtr() and sqlite3GetVarint32() are implemented */
if( nCellKey<=0 || nCellKey>0x7fffffff ){
rc = SQLITE_CORRUPT_BKPT;
goto abort_due_to_error;
}
sqlite3VdbeMemInit(&m, db, 0);
rc = sqlite3VdbeMemFromBtreeZeroOffset(pCur, (u32)nCellKey, &m);
if( rc ) goto abort_due_to_error;
res = sqlite3VdbeRecordCompareWithSkip(m.n, m.z, &r, 0);
sqlite3VdbeMemRelease(&m);
}
/* End of inlined sqlite3VdbeIdxKeyCompare() */
assert( (OP_IdxLE&1)==(OP_IdxLT&1) && (OP_IdxGE&1)==(OP_IdxGT&1) );
if( (pOp->opcode&1)==(OP_IdxLT&1) ){
assert( pOp->opcode==OP_IdxLE || pOp->opcode==OP_IdxLT );
@@ -6037,7 +6060,7 @@ case OP_IdxGE: { /* jump */
res++;
}
VdbeBranchTaken(res>0,2);
if( rc ) goto abort_due_to_error;
assert( rc==SQLITE_OK );
if( res>0 ) goto jump_to_p2;
break;
}