]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Performance optimization in btreeParseCellPtr() by unrolling the loop that
authordrh <>
Sun, 2 Jan 2022 16:48:00 +0000 (16:48 +0000)
committerdrh <>
Sun, 2 Jan 2022 16:48:00 +0000 (16:48 +0000)
decodes the rowid.

FossilOrigin-Name: fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e

manifest
manifest.uuid
src/btree.c

index fee691766c998071485f0312b6c2f071ca740991..89b61494cbdf5427ed0d5ff52b4ab6b7e23f3eba 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Small\sperformance\soptimization\sand\ssize\sreduction\sin\ssqlite3BtreeDelete().
-D 2022-01-02T14:55:43.095
+C Performance\soptimization\sin\sbtreeParseCellPtr()\sby\sunrolling\sthe\sloop\sthat\ndecodes\sthe\srowid.
+D 2022-01-02T16:48:00.312
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -491,7 +491,7 @@ F src/auth.c f4fa91b6a90bbc8e0d0f738aa284551739c9543a367071f55574681e0f24f8cf
 F src/backup.c 3014889fa06e20e6adfa0d07b60097eec1f6e5b06671625f476a714d2356513d
 F src/bitvec.c 7c849aac407230278445cb069bebc5f89bf2ddd87c5ed9459b070a9175707b3d
 F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6
-F src/btree.c d4b6e026d85b47018dd4c31b42dd490ed22d4320917e705d6502e589d1a8227d
+F src/btree.c 75aed1a53f45c9020d57ead65397693fe28e408526c08d2b15803629619eb4b7
 F src/btree.h 74d64b8f28cfa4a894d14d4ed64fa432cd697b98b61708d4351482ae15913e22
 F src/btreeInt.h ee9348c4cb9077243b049edc93a82c1f32ca48baeabf2140d41362b9f9139ff7
 F src/build.c 6e16f7b539bfc55149a039bf0cda26b089640339df6147070b072df2d1c4f771
@@ -1936,8 +1936,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 5232c9777fe4fb13e1ecfe5b5d644e2c45d0514f95884dbed49a03fb9b67304c
-R aa110e7b5297811807e4f693fefdef54
+P da0af4dd9ba4180a16543fac1549fd4ccecdc66dcf6d275f77de21fd80708882
+R 8e54a2cff16f34421db02383c81bf96e
 U drh
-Z a31d2467491c7884583c9d9e2a7c5425
+Z 07304ae249bd8afb301d4ea202109e15
 # Remove this line to create a well-formed Fossil manifest.
index 71edf50ae92b95f1e360551d4fee31c1bc17490f..a2fb6d3baa4844e4aceddeb282ca86a57183eb3e 100644 (file)
@@ -1 +1 @@
-da0af4dd9ba4180a16543fac1549fd4ccecdc66dcf6d275f77de21fd80708882
\ No newline at end of file
+fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
\ No newline at end of file
index 4f777f0f75bd188fac66c801ad514533225b8e0e..b99045c41e9a9fd5959e976d991d465264e2eaa0 100644 (file)
@@ -1225,18 +1225,32 @@ static void btreeParseCellPtr(
   **
   **     pIter += getVarint(pIter, (u64*)&pInfo->nKey);
   **
-  ** The code is inlined to avoid a function call.
+  ** The code is inlined and the loop is unrolled for performance.
+  ** This routine is a high-runner.
   */
   iKey = *pIter;
   if( iKey>=0x80 ){
-    u8 *pEnd = &pIter[7];
-    iKey &= 0x7f;
-    while(1){
-      iKey = (iKey<<7) | (*++pIter & 0x7f);
-      if( (*pIter)<0x80 ) break;
-      if( pIter>=pEnd ){
-        iKey = (iKey<<8) | *++pIter;
-        break;
+    u8 x;
+    iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
+    if( x>=0x80 ){
+      iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
+      if( x>=0x80 ){
+        iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+        if( x>=0x80 ){
+          iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+          if( x>=0x80 ){
+            iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+            if( x>=0x80 ){
+              iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+              if( x>=0x80 ){
+                iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
+                if( x>=0x80 ){
+                  iKey = (iKey<<8) | (*++pIter);
+                }
+              }
+            }
+          }
+        }
       }
     }
   }