/ Check-in [b02849e7]
Login

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

Overview
Comment:Add QNX-specific performance tweaks to the unix VFS.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.7.9
Files: files | file ages | folders
SHA1: b02849e7bde458dd8a2d91892f18bae7fdc7724d
User & Date: drh 2012-10-05 19:10:02
References
2012-10-26
13:46
Add QNX-specific performance tweaks to the unix VFS. (Cherry-pick merge of [b02849e7bde458].) check-in: 63a7dd75 user: drh tags: trunk
13:25
Add QNX-specific performance tweaks to the unix VFS. (Cherry-pick merge of [b02849e7bde458].) Put auxiliary libraries after libsqlite3.a in the testfixture target of the "main.mk" makefile. (Cherry-pick merge of [8fc8548f52ab8fcfb5].) check-in: cbfd1b12 user: drh tags: branch-3.7.14
Context
2012-10-15
23:15
Change the ICU tokenizer so that it does not attempt to call strlen(NULL). This is a cherry-pick of the fix in [04298f1ac42c40c] on 2012-03-31 first appearing in release 3.7.12. check-in: 49ffbc11 user: drh tags: branch-3.7.9
2012-10-05
19:10
Add QNX-specific performance tweaks to the unix VFS. check-in: b02849e7 user: drh tags: branch-3.7.9
18:38
Fix an accidental fork on branch-3.7.9. check-in: cd9efeb3 user: drh tags: branch-3.7.9
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   212    212     unsigned char ctrlFlags;            /* Behavioral bits.  UNIXFILE_* flags */
   213    213     int lastErrno;                      /* The unix errno from last I/O error */
   214    214     void *lockingContext;               /* Locking style specific state */
   215    215     UnixUnusedFd *pUnused;              /* Pre-allocated UnixUnusedFd */
   216    216     const char *zPath;                  /* Name of the file */
   217    217     unixShm *pShm;                      /* Shared memory segment information */
   218    218     int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
          219  +#ifdef __QNXNTO__
          220  +  int sectorSize;                     /* Device sector size */
          221  +  int deviceCharacteristics;          /* Precomputed device characteristics */
          222  +#endif
   219    223   #if SQLITE_ENABLE_LOCKING_STYLE
   220    224     int openFlags;                      /* The flags specified at open() */
   221    225   #endif
   222    226   #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
   223    227     unsigned fsFlags;                   /* cached details from statfs() */
   224    228   #endif
   225    229   #if OS_VXWORKS
................................................................................
  3543   3547   ** larger for some devices.
  3544   3548   **
  3545   3549   ** SQLite code assumes this function cannot fail. It also assumes that
  3546   3550   ** if two files are created in the same file-system directory (i.e.
  3547   3551   ** a database and its journal file) that the sector size will be the
  3548   3552   ** same for both.
  3549   3553   */
         3554  +#ifndef __QNXNTO__ 
  3550   3555   static int unixSectorSize(sqlite3_file *NotUsed){
  3551   3556     UNUSED_PARAMETER(NotUsed);
  3552   3557     return SQLITE_DEFAULT_SECTOR_SIZE;
  3553   3558   }
         3559  +#endif
         3560  +
         3561  +/*
         3562  +** The following version of unixSectorSize() is optimized for QNX.
         3563  +*/
         3564  +#ifdef __QNXNTO__
         3565  +#include <sys/dcmd_blk.h>
         3566  +#include <sys/statvfs.h>
         3567  +static int unixSectorSize(sqlite3_file *id){
         3568  +  unixFile *pFile = (unixFile*)id;
         3569  +  if( pFile->sectorSize == 0 ){
         3570  +    struct statvfs fsInfo;
         3571  +       
         3572  +    /* Set defaults for non-supported filesystems */
         3573  +    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
         3574  +    pFile->deviceCharacteristics = 0;
         3575  +    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {
         3576  +      return pFile->sectorSize;
         3577  +    }
         3578  +
         3579  +    if( !strcmp(fsInfo.f_basetype, "tmp") ) {
         3580  +      pFile->sectorSize = fsInfo.f_bsize;
         3581  +      pFile->deviceCharacteristics =
         3582  +        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */
         3583  +        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
         3584  +                                      ** the write succeeds */
         3585  +        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
         3586  +                                      ** so it is ordered */
         3587  +        0;
         3588  +    }else if( strstr(fsInfo.f_basetype, "etfs") ){
         3589  +      pFile->sectorSize = fsInfo.f_bsize;
         3590  +      pFile->deviceCharacteristics =
         3591  +        /* etfs cluster size writes are atomic */
         3592  +        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |
         3593  +        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
         3594  +                                      ** the write succeeds */
         3595  +        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
         3596  +                                      ** so it is ordered */
         3597  +        0;
         3598  +    }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){
         3599  +      pFile->sectorSize = fsInfo.f_bsize;
         3600  +      pFile->deviceCharacteristics =
         3601  +        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */
         3602  +        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
         3603  +                                      ** the write succeeds */
         3604  +        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
         3605  +                                      ** so it is ordered */
         3606  +        0;
         3607  +    }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){
         3608  +      pFile->sectorSize = fsInfo.f_bsize;
         3609  +      pFile->deviceCharacteristics =
         3610  +        /* full bitset of atomics from max sector size and smaller */
         3611  +        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
         3612  +        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
         3613  +                                      ** so it is ordered */
         3614  +        0;
         3615  +    }else if( strstr(fsInfo.f_basetype, "dos") ){
         3616  +      pFile->sectorSize = fsInfo.f_bsize;
         3617  +      pFile->deviceCharacteristics =
         3618  +        /* full bitset of atomics from max sector size and smaller */
         3619  +        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
         3620  +        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
         3621  +                                      ** so it is ordered */
         3622  +        0;
         3623  +    }else{
         3624  +      pFile->deviceCharacteristics =
         3625  +        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */
         3626  +        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
         3627  +                                      ** the write succeeds */
         3628  +        0;
         3629  +    }
         3630  +  }
         3631  +  /* Last chance verification.  If the sector size isn't a multiple of 512
         3632  +  ** then it isn't valid.*/
         3633  +  if( pFile->sectorSize % 512 != 0 ){
         3634  +    pFile->deviceCharacteristics = 0;
         3635  +    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
         3636  +  }
         3637  +  return pFile->sectorSize;
         3638  +}
         3639  +#endif /* __QNXNTO__ */
  3554   3640   
  3555   3641   /*
  3556   3642   ** Return the device characteristics for the file. This is always 0 for unix.
  3557   3643   */
  3558         -static int unixDeviceCharacteristics(sqlite3_file *NotUsed){
  3559         -  UNUSED_PARAMETER(NotUsed);
         3644  +static int unixDeviceCharacteristics(sqlite3_file *id){
         3645  +#ifdef __QNXNTO__
         3646  +  unixFile *p = (unixFile*)id;
         3647  +  if( p->sectorSize==0 ) unixSectorSize(id);
         3648  +  return p->deviceCharacteristics;
         3649  +#else
  3560   3650     return 0;
         3651  +#endif
  3561   3652   }
  3562   3653   
  3563   3654   #ifndef SQLITE_OMIT_WAL
  3564   3655   
  3565   3656   
  3566   3657   /*
  3567   3658   ** Object used to represent an shared memory buffer.