]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add QNX-specific performance tweaks to the unix VFS.
authordrh <drh@noemail.net>
Fri, 5 Oct 2012 19:10:02 +0000 (19:10 +0000)
committerdrh <drh@noemail.net>
Fri, 5 Oct 2012 19:10:02 +0000 (19:10 +0000)
FossilOrigin-Name: b02849e7bde458dd8a2d91892f18bae7fdc7724d

manifest
manifest.uuid
src/os_unix.c

index b172af78cd0fc891c9909f37b6fd05055a88a0b4..8746e1fab3d6db5fc951586758a17e33ca5a1d2b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\saccidental\sfork\son\sbranch-3.7.9.
-D 2012-10-05T18:38:26.507
+C Add\sQNX-specific\sperformance\stweaks\sto\sthe\sunix\sVFS.
+D 2012-10-05T19:10:02.654
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a162fe39e249b8ed4a65ee947c30152786cfe897
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/os.c 5d9b02782ed36345348d6fe21d7762ed3a9cfd2a
 F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
-F src/os_unix.c ddda0b1c5ae536669634d7bff31b3f8f4d654866
+F src/os_unix.c 97c346f849b0aeb8f1556141ee1875db5f1f6357
 F src/os_win.c 49d418916428a59d773f39993db0ecde56ab4c37
 F src/pager.c ad62daa0c21e27ae332b3ceb4f579a2a97046ddc
 F src/pager.h 9f81b08efb06db4ba8be69446e10b005c351373d
@@ -974,7 +974,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P ac81ae493f97e415f13ef517b0ff88a901bc276f 54cc11981127b52145e39f551d958580b1d45169
-R e6e980702c7bf7d25933d028023d21d6
+P cd9efeb3eb28efc6a92904bb426c3a50f95fc936
+R 8d36bc7b5efb431bf0071d11802397d7
 U drh
-Z 2d38929805a1813ccf9d39994a17a70d
+Z 13a2888935ea7f47b8176999fa77e5ac
index d31f315a862ad575c778bf307a610f73d7114277..c2ebebcd1c6341450c337470170b9d119b7f79c4 100644 (file)
@@ -1 +1 @@
-cd9efeb3eb28efc6a92904bb426c3a50f95fc936
\ No newline at end of file
+b02849e7bde458dd8a2d91892f18bae7fdc7724d
\ No newline at end of file
index 0ea6daf27fe0613cff67fcc3186f8e3b1e4e5b4a..e61942c218607437a04b3523bb23fc535da94aec 100644 (file)
@@ -216,6 +216,10 @@ struct unixFile {
   const char *zPath;                  /* Name of the file */
   unixShm *pShm;                      /* Shared memory segment information */
   int szChunk;                        /* Configured by FCNTL_CHUNK_SIZE */
+#ifdef __QNXNTO__
+  int sectorSize;                     /* Device sector size */
+  int deviceCharacteristics;          /* Precomputed device characteristics */
+#endif
 #if SQLITE_ENABLE_LOCKING_STYLE
   int openFlags;                      /* The flags specified at open() */
 #endif
@@ -3547,17 +3551,104 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
 ** a database and its journal file) that the sector size will be the
 ** same for both.
 */
+#ifndef __QNXNTO__ 
 static int unixSectorSize(sqlite3_file *NotUsed){
   UNUSED_PARAMETER(NotUsed);
   return SQLITE_DEFAULT_SECTOR_SIZE;
 }
+#endif
+
+/*
+** The following version of unixSectorSize() is optimized for QNX.
+*/
+#ifdef __QNXNTO__
+#include <sys/dcmd_blk.h>
+#include <sys/statvfs.h>
+static int unixSectorSize(sqlite3_file *id){
+  unixFile *pFile = (unixFile*)id;
+  if( pFile->sectorSize == 0 ){
+    struct statvfs fsInfo;
+       
+    /* Set defaults for non-supported filesystems */
+    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
+    pFile->deviceCharacteristics = 0;
+    if( fstatvfs(pFile->h, &fsInfo) == -1 ) {
+      return pFile->sectorSize;
+    }
+
+    if( !strcmp(fsInfo.f_basetype, "tmp") ) {
+      pFile->sectorSize = fsInfo.f_bsize;
+      pFile->deviceCharacteristics =
+        SQLITE_IOCAP_ATOMIC4K |       /* All ram filesystem writes are atomic */
+        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
+                                      ** the write succeeds */
+        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
+                                      ** so it is ordered */
+        0;
+    }else if( strstr(fsInfo.f_basetype, "etfs") ){
+      pFile->sectorSize = fsInfo.f_bsize;
+      pFile->deviceCharacteristics =
+        /* etfs cluster size writes are atomic */
+        (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |
+        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
+                                      ** the write succeeds */
+        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
+                                      ** so it is ordered */
+        0;
+    }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){
+      pFile->sectorSize = fsInfo.f_bsize;
+      pFile->deviceCharacteristics =
+        SQLITE_IOCAP_ATOMIC |         /* All filesystem writes are atomic */
+        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
+                                      ** the write succeeds */
+        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
+                                      ** so it is ordered */
+        0;
+    }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){
+      pFile->sectorSize = fsInfo.f_bsize;
+      pFile->deviceCharacteristics =
+        /* full bitset of atomics from max sector size and smaller */
+        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
+        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
+                                      ** so it is ordered */
+        0;
+    }else if( strstr(fsInfo.f_basetype, "dos") ){
+      pFile->sectorSize = fsInfo.f_bsize;
+      pFile->deviceCharacteristics =
+        /* full bitset of atomics from max sector size and smaller */
+        ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
+        SQLITE_IOCAP_SEQUENTIAL |     /* The ram filesystem has no write behind
+                                      ** so it is ordered */
+        0;
+    }else{
+      pFile->deviceCharacteristics =
+        SQLITE_IOCAP_ATOMIC512 |      /* blocks are atomic */
+        SQLITE_IOCAP_SAFE_APPEND |    /* growing the file does not occur until
+                                      ** the write succeeds */
+        0;
+    }
+  }
+  /* Last chance verification.  If the sector size isn't a multiple of 512
+  ** then it isn't valid.*/
+  if( pFile->sectorSize % 512 != 0 ){
+    pFile->deviceCharacteristics = 0;
+    pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
+  }
+  return pFile->sectorSize;
+}
+#endif /* __QNXNTO__ */
 
 /*
 ** Return the device characteristics for the file. This is always 0 for unix.
 */
-static int unixDeviceCharacteristics(sqlite3_file *NotUsed){
-  UNUSED_PARAMETER(NotUsed);
+static int unixDeviceCharacteristics(sqlite3_file *id){
+#ifdef __QNXNTO__
+  unixFile *p = (unixFile*)id;
+  if( p->sectorSize==0 ) unixSectorSize(id);
+  return p->deviceCharacteristics;
+#else
   return 0;
+#endif
 }
 
 #ifndef SQLITE_OMIT_WAL