/ Check-in [7a234fc3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid unnecessary calls to sqlite3VarintLen() from the OP_MakeRecord opcode.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7a234fc3c5e7970ffe0b8d6ac33c26acb64b5c4d
User & Date: drh 2013-12-08 22:59:29
Context
2013-12-08
23:33
Another simplification to the OP_MakeRecord opcode, making it slightly faster and very slightly smaller. check-in: f2f5a3ce user: drh tags: trunk
22:59
Avoid unnecessary calls to sqlite3VarintLen() from the OP_MakeRecord opcode. check-in: 7a234fc3 user: drh tags: trunk
19:54
Interchange two conditions in an "if" statment in sqlite3PagerAcquire() for very slight (0.06%) overall performance increase. check-in: fbcc1a3e user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  2604   2604       }
  2605   2605       if( pRec->flags&MEM_Zero && pRec->n>0 ){
  2606   2606         sqlite3VdbeMemExpandBlob(pRec);
  2607   2607       }
  2608   2608       serial_type = sqlite3VdbeSerialType(pRec, file_format);
  2609   2609       len = sqlite3VdbeSerialTypeLen(serial_type);
  2610   2610       nData += len;
  2611         -    nHdr += sqlite3VarintLen(serial_type);
         2611  +    nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);
  2612   2612       if( pRec->flags & MEM_Zero ){
  2613   2613         /* Only pure zero-filled BLOBs can be input to this Opcode.
  2614   2614         ** We do not allow blobs with a prefix and a zero-filled tail. */
  2615   2615         nZero += pRec->u.nZero;
  2616   2616       }else if( len ){
  2617   2617         nZero = 0;
  2618   2618       }
  2619   2619     }
  2620   2620   
  2621   2621     /* Add the initial header varint and total the size */
  2622         -  nHdr += nVarint = sqlite3VarintLen(nHdr);
  2623         -  if( nVarint<sqlite3VarintLen(nHdr) ){
  2624         -    nHdr++;
         2622  +  if( nHdr<=126 ){
         2623  +    /* The common case */
         2624  +    nHdr += 1;
         2625  +  }else{
         2626  +    /* Rare case of a really large header */
         2627  +    nVarint = sqlite3VarintLen(nHdr);
         2628  +    nHdr += nVarint;
         2629  +    if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
  2625   2630     }
  2626   2631     nByte = nHdr+nData-nZero;
  2627   2632     if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
  2628   2633       goto too_big;
  2629   2634     }
  2630   2635   
  2631   2636     /* Make sure the output register has a buffer large enough to store