]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
A new version of the slow mutex log that uses gettimeofday() instead of
authordrh <drh@noemail.net>
Sat, 30 Jul 2016 03:33:30 +0000 (03:33 +0000)
committerdrh <drh@noemail.net>
Sat, 30 Jul 2016 03:33:30 +0000 (03:33 +0000)
trying to access the hardware timer.

FossilOrigin-Name: 92b9fead353d50eb41f5ab7e3a887dd4e5c3aa80

manifest
manifest.uuid
src/mutex_unix.c

index 4714c1debcdd67649cd0c7c73c01a08f99c4b63c..8c6b45215aab5aa45a8cc42ef8bb791145a0f054 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Turn\smemory\sstatus\soff\sby\sdefault.
-D 2016-07-29T16:32:34.995
+C A\snew\sversion\sof\sthe\sslow\smutex\slog\sthat\suses\sgettimeofday()\sinstead\sof\ntrying\sto\saccess\sthe\shardware\stimer.
+D 2016-07-30T03:33:30.306
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -205,7 +205,7 @@ F src/memjournal.c 3eb2c0b51adbd869cb6a44780323f05fa904dc85
 F src/mutex.c 84a073c9a23a8d7bdd2ea832522d1730df18812c
 F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85
 F src/mutex_noop.c f3f09fd7a2eb4287cfc799753ffc30380e7b71a1
-F src/mutex_unix.c 3a24b5f2e46c3a676606a28ac5d00c0462231f98
+F src/mutex_unix.c 5cbf63bc6e2999eecbcfa883537c9eacf1484a62
 F src/mutex_w32.c 06bfff9a3a83b53389a51a967643db3967032e1e
 F src/notify.c 9711a7575036f0d3040ba61bc6e217f13a9888e7
 F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace
@@ -1207,7 +1207,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P e60cb6d8852ebf42659c7f2e86a1f6a2492b4664
-R 2e00b38dde15987fc42ae9a66ffe8ce5
+P ea3c7162dc79cb85868d2bc86d9938fe7c2ae7ef
+R 4317055374b4abe2abea36440aabee15
 U drh
-Z 8a353085af5bf0ee7487739267eafd01
+Z d3037cc2511d419210d869068053f9a1
index eb69715147825834a42f52b2d0aede405446896c..06b489ad7c6a6bb631e9b7aa4b3b5a849bce1f0f 100644 (file)
@@ -1 +1 @@
-ea3c7162dc79cb85868d2bc86d9938fe7c2ae7ef
\ No newline at end of file
+92b9fead353d50eb41f5ab7e3a887dd4e5c3aa80
\ No newline at end of file
index 3ef651b0d2aa34cab499a8a6df42baa9347be0f1..59b0ec97bca4f332e22a77feff6eb2e16913789f 100644 (file)
@@ -200,7 +200,7 @@ static void pthreadMutexFree(sqlite3_mutex *p){
   sqlite3_free(p);
 }
 
-#include "hwtime.h"
+#include <sys/time.h>
 #ifdef SQLITE_MUTEX_NREF
 # define MUTEX_ID(p)  (p->id)
 #else
@@ -219,9 +219,12 @@ static void pthreadMutexFree(sqlite3_mutex *p){
 ** more than once, the behavior is undefined.
 */
 static void pthreadMutexEnter(sqlite3_mutex *p){
-  sqlite3_uint64 iTimer = sqlite3Hwtime();
+  struct timeval x;
+  sqlite3_uint64 iBegin, iEnd;
   assert( p->id==SQLITE_MUTEX_RECURSIVE || pthreadMutexNotheld(p) );
 
+  gettimeofday(&x, 0);
+  iBegin = 1000000*(sqlite3_uint64)x.tv_sec + x.tv_usec;
 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
   /* If recursive mutexes are not available, then we have to grow
   ** our own.  This implementation assumes that pthread_equal()
@@ -253,15 +256,16 @@ static void pthreadMutexEnter(sqlite3_mutex *p){
   p->owner = pthread_self();
   p->nRef++;
 #endif
-  iTimer = sqlite3Hwtime() - iTimer;
-  if( iTimer>100000 ){
+  gettimeofday(&x, 0);
+  iEnd = 1000000*(sqlite3_uint64)x.tv_sec + x.tv_usec;
+  if( iEnd > iBegin+500 ){
     sqlite3_mutex *pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
     int id = -1;
     if( p>=pMaster && p<=&pMaster[SQLITE_MUTEX_STATIC_APP3-2] ){
       id = (int)(p - pMaster) + 2;
     }
-    sqlite3_log(SQLITE_NOTICE, "slow mutex: %lld cycles on %d/%p",
-                iTimer, id, p);
+    sqlite3_log(SQLITE_NOTICE, "slow mutex: %llu uS on %d/%p",
+                iEnd - iBegin, id, p);
   }
 #endif