SQLite

Check-in [b05340fe3c]
Login

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

Overview
Comment:Increase the default minimum PMA size for multi-threaded sorting from 10x the page size to 250x the page size. Provide the SQLITE_SORTER_PMASZ compile-time option to change this default.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b05340fe3cd5f1676a55023228dc8d1a92de5936
User & Date: drh 2014-12-09 14:42:49.215
Context
2014-12-09
15:12
Add the SQLITE_REVERSE_UNORDERED_SELECTS compile-time option that causes the "PRAGMA reverse_unordered_selects" setting to be on by default. (check-in: 75a803e694 user: drh tags: trunk)
15:01
Increase the default PMA size from 10 to 250 pages and provide the SQLITE_SORTER_PMASZ compile-time option to change this default. Add needed mutex call when clearing the KeyInfo cache in shared-cache mode. (check-in: 6e2da589ad user: drh tags: apple-osx)
14:54
Merge the KeyInfo cache mutex fix from trunk. (check-in: f0940c73bd user: drh tags: sessions)
14:42
Increase the default minimum PMA size for multi-threaded sorting from 10x the page size to 250x the page size. Provide the SQLITE_SORTER_PMASZ compile-time option to change this default. (check-in: b05340fe3c user: drh tags: trunk)
04:26
Fix harmless compiler warning. (check-in: e97b7a8b4d user: mistachkin tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbesort.c.
446
447
448
449
450
451
452

453

454
455
456
457
458
459
460
**
**   void *SRVAL(SorterRecord *p) { return (void*)&p[1]; }
*/
#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))

/* The minimum PMA size is set to this value multiplied by the database
** page size in bytes.  */

#define SORTER_MIN_WORKING 10


/* Maximum number of PMAs that a single MergeEngine can merge */
#define SORTER_MAX_MERGE_COUNT 16

static int vdbeIncrSwap(IncrMerger*);
static void vdbeIncrFree(IncrMerger *);








>
|
>







446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
**
**   void *SRVAL(SorterRecord *p) { return (void*)&p[1]; }
*/
#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))

/* The minimum PMA size is set to this value multiplied by the database
** page size in bytes.  */
#ifndef SQLITE_SORTER_PMASZ
# define SQLITE_SORTER_PMASZ 250
#endif

/* Maximum number of PMAs that a single MergeEngine can merge */
#define SORTER_MAX_MERGE_COUNT 16

static int vdbeIncrSwap(IncrMerger*);
static void vdbeIncrFree(IncrMerger *);

845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
    pSorter->db = db;
    for(i=0; i<pSorter->nTask; i++){
      SortSubtask *pTask = &pSorter->aTask[i];
      pTask->pSorter = pSorter;
    }

    if( !sqlite3TempInMemory(db) ){
      pSorter->mnPmaSize = SORTER_MIN_WORKING * pgsz;
      mxCache = db->aDb[0].pSchema->cache_size;
      if( mxCache<SORTER_MIN_WORKING ) mxCache = SORTER_MIN_WORKING;
      pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_MXPMASIZE);

      /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
      ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
      ** large heap allocations.
      */
      if( sqlite3GlobalConfig.pScratch==0 ){







|

|







847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
    pSorter->db = db;
    for(i=0; i<pSorter->nTask; i++){
      SortSubtask *pTask = &pSorter->aTask[i];
      pTask->pSorter = pSorter;
    }

    if( !sqlite3TempInMemory(db) ){
      pSorter->mnPmaSize = SQLITE_SORTER_PMASZ * pgsz;
      mxCache = db->aDb[0].pSchema->cache_size;
      if( mxCache<SQLITE_SORTER_PMASZ ) mxCache = SQLITE_SORTER_PMASZ;
      pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_MXPMASIZE);

      /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
      ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
      ** large heap allocations.
      */
      if( sqlite3GlobalConfig.pScratch==0 ){