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

Minor simplification and performance optimization for Direct Overflow Read.

FossilOrigin-Name: 3e96d6efa867b765c8acf1454014b1e71b2e4f21
This commit is contained in:
drh
2017-01-26 16:27:32 +00:00
parent d930b5cb06
commit 8bb9fd3b45
3 changed files with 16 additions and 22 deletions

View File

@@ -1,5 +1,5 @@
C Make\sSQLITE_DIRECT_OVERFLOW_READ\swork\sfor\sin\sWAL\smode\sas\slong\sas\sthe\spage\nbeing\sread\sis\snot\sin\sthe\sthe\s-wal\sfile. C Minor\ssimplification\sand\sperformance\soptimization\sfor\sDirect\sOverflow\sRead.
D 2017-01-26T02:26:02.936 D 2017-01-26T16:27:32.813
F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc F Makefile.in 5f415e7867296d678fed2e6779aea10c1318b4bc
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
@@ -333,7 +333,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792
F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b
F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33
F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca
F src/btree.c 4a4ae5fd82ee576b85163277610d8b8174831f16 F src/btree.c a168da7c4fff00dbd939c49ad4445d378eff1b11
F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac
F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e
F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af
@@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 62a4851ccf88837d1c16dae8204f7f264e80e3c9 P 9879be1899adf5634f551a2077b15ccb1133e4e3
R 5def997b16301f95d47461ef6a1c2e30 R d7cd9a6ab86d59aef41165d7cf109b11
U drh U drh
Z c8beae43adff961172e88276d51d2aaf Z 50b1b915cab08ae10917e730aa3424e6

View File

@@ -1 +1 @@
9879be1899adf5634f551a2077b15ccb1133e4e3 3e96d6efa867b765c8acf1454014b1e71b2e4f21

View File

@@ -4460,8 +4460,7 @@ static int accessPayload(
MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */ MemPage *pPage = pCur->apPage[pCur->iPage]; /* Btree page of current entry */
BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */ BtShared *pBt = pCur->pBt; /* Btree this cursor belongs to */
#ifdef SQLITE_DIRECT_OVERFLOW_READ #ifdef SQLITE_DIRECT_OVERFLOW_READ
unsigned char * const pBufStart = pBuf; unsigned char * const pBufStart = pBuf; /* Start of original out buffer */
int bEnd; /* True if reading to end of data */
#endif #endif
assert( pPage ); assert( pPage );
@@ -4472,9 +4471,6 @@ static int accessPayload(
getCellInfo(pCur); getCellInfo(pCur);
aPayload = pCur->info.pPayload; aPayload = pCur->info.pPayload;
#ifdef SQLITE_DIRECT_OVERFLOW_READ
bEnd = offset+amt==pCur->info.nPayload;
#endif
assert( offset+amt <= pCur->info.nPayload ); assert( offset+amt <= pCur->info.nPayload );
assert( aPayload > pPage->aData ); assert( aPayload > pPage->aData );
@@ -4579,7 +4575,7 @@ static int accessPayload(
** range of data that is being read (eOp==0) or written (eOp!=0). ** range of data that is being read (eOp==0) or written (eOp!=0).
*/ */
#ifdef SQLITE_DIRECT_OVERFLOW_READ #ifdef SQLITE_DIRECT_OVERFLOW_READ
sqlite3_file *fd; sqlite3_file *fd; /* File from which to do direct overflow read */
#endif #endif
int a = amt; int a = amt;
if( a + offset > ovflSize ){ if( a + offset > ovflSize ){
@@ -4591,11 +4587,10 @@ static int accessPayload(
** **
** 1) this is a read operation, and ** 1) this is a read operation, and
** 2) data is required from the start of this overflow page, and ** 2) data is required from the start of this overflow page, and
** 3) the database is file-backed, and ** 3) there is no open write-transaction, and
** 4) there is no open write-transaction, and ** 4) the database is file-backed, and
** 5) the page is not in the WAL file ** 5) the page is not in the WAL file
** 6) all data from the page is being read. ** 6) at least 4 bytes have already been read into the output buffer
** 7) at least 4 bytes have already been read into the output buffer
** **
** then data can be read directly from the database file into the ** then data can be read directly from the database file into the
** output buffer, bypassing the page-cache altogether. This speeds ** output buffer, bypassing the page-cache altogether. This speeds
@@ -4603,15 +4598,14 @@ static int accessPayload(
*/ */
if( (eOp&0x01)==0 /* (1) */ if( (eOp&0x01)==0 /* (1) */
&& offset==0 /* (2) */ && offset==0 /* (2) */
&& (bEnd || a==ovflSize) /* (6) */ && pBt->inTransaction==TRANS_READ /* (3) */
&& pBt->inTransaction==TRANS_READ /* (4) */ && (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (4) */
&& (fd = sqlite3PagerFile(pBt->pPager))->pMethods /* (3) */
&& 0==sqlite3PagerUseWal(pBt->pPager, nextPage) /* (5) */ && 0==sqlite3PagerUseWal(pBt->pPager, nextPage) /* (5) */
&& &pBuf[-4]>=pBufStart /* (7) */ && &pBuf[-4]>=pBufStart /* (6) */
){ ){
u8 aSave[4]; u8 aSave[4];
u8 *aWrite = &pBuf[-4]; u8 *aWrite = &pBuf[-4];
assert( aWrite>=pBufStart ); /* hence (7) */ assert( aWrite>=pBufStart ); /* due to (6) */
memcpy(aSave, aWrite, 4); memcpy(aSave, aWrite, 4);
rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1)); rc = sqlite3OsRead(fd, aWrite, a+4, (i64)pBt->pageSize*(nextPage-1));
nextPage = get4byte(aWrite); nextPage = get4byte(aWrite);