From: stephan Date: Fri, 25 Aug 2023 04:27:17 +0000 (+0000) Subject: Only build in the JNI-side metrics tracking in SQLITE_DEBUG builds. X-Git-Tag: version-3.44.0~293 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ecb51c260d49edbac05d7f0197af3d07560a188;p=thirdparty%2Fsqlite.git Only build in the JNI-side metrics tracking in SQLITE_DEBUG builds. FossilOrigin-Name: 646e7fc3b5ba81c207f013c9a06781986138379f20e787320a811ba3ed5489dc --- diff --git a/ext/jni/GNUmakefile b/ext/jni/GNUmakefile index 5cd9c0dff0..366c6329e9 100644 --- a/ext/jni/GNUmakefile +++ b/ext/jni/GNUmakefile @@ -224,7 +224,7 @@ sqlite3-jni.dll.cflags = \ # include path for client-level code. ######################################################################## ifeq (1,$(enable.tester)) - sqlite3-jni.dll.cflags += -DS3JNI_ENABLE_SQLTester + sqlite3-jni.dll.cflags += -DSQLITE_JNI_ENABLE_SQLTester endif $(sqlite3-jni.h): $(sqlite3-jni.h.in) $(MAKEFILE) cat $(sqlite3-jni.h.in) > $@ diff --git a/ext/jni/src/c/sqlite3-jni.c b/ext/jni/src/c/sqlite3-jni.c index 757d813a04..0d2adff5aa 100644 --- a/ext/jni/src/c/sqlite3-jni.c +++ b/ext/jni/src/c/sqlite3-jni.c @@ -410,14 +410,24 @@ struct S3JniAutoExtension { jmethodID midFunc /* xEntryPoint() callback */; }; +#if !defined(SQLITE_JNI_OMIT_METRICS) && !defined(SQLITE_JNI_ENABLE_METRICS) +# ifdef SQLITE_DEBUG +# define SQLITE_JNI_ENABLE_METRICS +# endif +#endif + /* ** If true, modifying S3JniGlobal.metrics is protected by a mutex, ** else it isn't. */ #ifdef SQLITE_DEBUG -#define S3JNI_METRICS_MUTEX 1 +# define S3JNI_METRICS_MUTEX 1 #else -#define S3JNI_METRICS_MUTEX 0 +# define S3JNI_METRICS_MUTEX 0 +#endif +#ifndef SQLITE_JNI_ENABLE_METRICS +# undef S3JNI_METRICS_MUTEX +# define S3JNI_METRICS_MUTEX 0 #endif /* @@ -490,6 +500,7 @@ struct S3JniGlobalType { } jPhraseIter; } fts5; #endif +#ifdef SQLITE_JNI_ENABLE_METRICS /* Internal metrics. */ struct { volatile unsigned envCacheHits; @@ -517,6 +528,7 @@ struct S3JniGlobalType { sqlite3_mutex * mutex; #endif } metrics; +#endif /* SQLITE_JNI_ENABLE_METRICS */ /** The list of bound auto-extensions (Java-side: org.sqlite.jni.auto_extension objects). @@ -534,7 +546,9 @@ static S3JniGlobalType S3JniGlobal = {}; #define SJG S3JniGlobal /* Increments *p, possibly protected by a mutex. */ -#if S3JNI_METRICS_MUTEX +#ifndef SQLITE_JNI_ENABLE_METRICS +#define s3jni_incr(PTR) +#elif S3JNI_METRICS_MUTEX static void s3jni_incr( volatile unsigned int * const p ){ sqlite3_mutex * const m = SJG.metrics.mutex; sqlite3_mutex_enter(m); @@ -557,7 +571,7 @@ static void s3jni_incr( volatile unsigned int * const p ){ S3JniMutex_Env_assertNotLocker; \ /*MARKER(("Entering ENV mutex@%p %s.\n", env));*/ \ sqlite3_mutex_enter( SJG.envCache.mutex ); \ - ++SJG.metrics.nMutexEnv; \ + s3jni_incr(&SJG.metrics.nMutexEnv); \ SJG.envCache.locker = env #define S3JniMutex_Env_leave \ /*MARKER(("Leaving ENV mutex @%p %s.\n", env));*/ \ @@ -567,7 +581,7 @@ static void s3jni_incr( volatile unsigned int * const p ){ #define S3JniMutex_Ext_enter \ /*MARKER(("Entering autoExt mutex@%p %s.\n", env));*/ \ sqlite3_mutex_enter( SJG.autoExt.mutex ); \ - ++SJG.metrics.nMutexAutoExt + s3jni_incr( &SJG.metrics.nMutexAutoExt ) #define S3JniMutex_Ext_leave \ /*MARKER(("Leaving autoExt mutex@%p %s.\n", env));*/ \ sqlite3_mutex_leave( SJG.autoExt.mutex ) @@ -575,7 +589,7 @@ static void s3jni_incr( volatile unsigned int * const p ){ S3JniMutex_Env_assertNotLocker; \ /*MARKER(("Entering NPH mutex@%p %s.\n", env));*/ \ sqlite3_mutex_enter( SJG.envCache.mutex ); \ - ++SJG.metrics.nMutexEnv2; \ + s3jni_incr( &SJG.metrics.nMutexEnv2 ); \ SJG.envCache.locker = env #define S3JniMutex_Nph_leave \ /*MARKER(("Leaving NPH mutex @%p %s.\n", env));*/ \ @@ -585,7 +599,7 @@ static void s3jni_incr( volatile unsigned int * const p ){ #define S3JniMutex_S3JniDb_enter \ sqlite3_mutex_enter( SJG.perDb.mutex ); \ assert( 0==SJG.perDb.locker ); \ - ++SJG.metrics.nMutexPerDb; \ + s3jni_incr( &SJG.metrics.nMutexPerDb ); \ SJG.perDb.locker = env; #define S3JniMutex_S3JniDb_leave \ /*MARKER(("Leaving PerDb mutex@%p %s.\n", env));*/ \ @@ -829,7 +843,7 @@ static char * s3jni_exception_error_msg(JNIEnv * const env, jthrowable jx ){ } /* -** Extracts the current JNI exception, sets ps->pDb's error message to +** Extracts env's current exception, sets ps->pDb's error message to ** its message string, and clears the exception. If errCode is non-0, ** it is used as-is, else SQLITE_ERROR is assumed. If there's a ** problem extracting the exception's message, it's treated as @@ -853,7 +867,7 @@ static int s3jni_db_exception(JNIEnv * const env, S3JniDb * const ps, sqlite3_free(zMsg); S3JniUnrefLocal(ex); } - return errCode; + return errCode; } /* @@ -3816,6 +3830,8 @@ JniDecl(void,1jni_1internal_1details)(JniArgsEnvClass){ SO(S3JniGlobal); SO(S3JniAutoExtension); SO(S3JniUdf); +#undef SO +#ifdef SQLITE_JNI_ENABLE_METRICS printf("Cache info:\n"); printf("\tJNIEnv cache: %u allocs, %u misses, %u hits\n", SJG.metrics.envCacheAllocs, @@ -3840,7 +3856,9 @@ JniDecl(void,1jni_1internal_1details)(JniArgsEnvClass){ #undef UDF printf("xDestroy calls across all callback types: %u\n", SJG.metrics.nDestroy); -#undef SO +#else + puts("Built without SQLITE_JNI_ENABLE_METRICS."); +#endif } //////////////////////////////////////////////////////////////////////// @@ -4444,7 +4462,7 @@ JniDeclFtsXA(jobject,xUserData)(JniArgsEnvObj,jobject jFcx){ // End of the main API bindings. Start of SQLTester bits... //////////////////////////////////////////////////////////////////////// -#ifdef S3JNI_ENABLE_SQLTester +#ifdef SQLITE_JNI_ENABLE_SQLTester typedef struct SQLTesterJni SQLTesterJni; struct SQLTesterJni { sqlite3_int64 nDup; @@ -4640,7 +4658,7 @@ Java_org_sqlite_jni_tester_SQLTester_installCustomExtensions(JniArgsEnvClass){ sqlite3_auto_extension( (void(*)(void))SQLTester_auto_extension ); } -#endif /* S3JNI_ENABLE_SQLTester */ +#endif /* SQLITE_JNI_ENABLE_SQLTester */ //////////////////////////////////////////////////////////////////////// // End of SQLTester bindings. Start of lower-level bits. //////////////////////////////////////////////////////////////////////// diff --git a/manifest b/manifest index 28dde1fc3f..5bde21390e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Javadoc\sand\sinternal\sAPI\scleanups. -D 2023-08-25T04:02:33.692 +C Only\sbuild\sin\sthe\sJNI-side\smetrics\stracking\sin\sSQLITE_DEBUG\sbuilds. +D 2023-08-25T04:27:17.217 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -233,10 +233,10 @@ F ext/fts5/tool/showfts5.tcl d54da0e067306663e2d5d523965ca487698e722c F ext/icu/README.txt 7ab7ced8ae78e3a645b57e78570ff589d4c672b71370f5aa9e1cd7024f400fc9 F ext/icu/icu.c c074519b46baa484bb5396c7e01e051034da8884bad1a1cb7f09bbe6be3f0282 F ext/icu/sqliteicu.h fa373836ed5a1ee7478bdf8a1650689294e41d0c89c1daab26e9ae78a32075a8 -F ext/jni/GNUmakefile fb73086e6f8ee40f3c79e32b8e0a27725b2680f9cf8ae41bde2556eb8e3fad2a +F ext/jni/GNUmakefile 2fe04e7a7534a069ea8448f42e95bb5f8fc279ea3c9883598acedc99bbc254a7 F ext/jni/README.md 1332b1fa27918bd5d9ca2d0d4f3ac3a6ab86b9e3699dc5bfe32904a027f3d2a9 F ext/jni/jar-dist.make 030aaa4ae71dd86e4ec5e7c1e6cd86f9dfa47c4592c070d2e35157e42498e1fa -F ext/jni/src/c/sqlite3-jni.c 2f9115f672f2bf2bca5ab58bdf8ef592099b7d8b8c44ffdfc5576399a18a0666 +F ext/jni/src/c/sqlite3-jni.c 969e59cdf9ad2394dcfc7b7fd3e259ff27cacfbe4946ccfdb8de6554745a32cb F ext/jni/src/c/sqlite3-jni.h 3d8cdacce26d20fd967d67a2e8539d38fc2e9fe13598147399db4b2c303a89c8 F ext/jni/src/org/sqlite/jni/Fts5.java a45cd890202d72c3bfe8aea69b57b02b6dd588361af81d8b921954c37940b2f7 F ext/jni/src/org/sqlite/jni/Fts5Context.java 0a5a02047a6a1dd3e4a38b0e542a8dd2de365033ba30e6ae019a676305959890 @@ -2100,8 +2100,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 76e62a381249b3b4262b22bdffe7fc2816c820115c9df266956ab8817b127aca -R 0c4026c894e1986e8dbcbf3bbc899b49 +P 10a43cba9bb2c23b5f31b31fcac81be34acec1940cca47d0b8e5a5ccbf1aa8eb +R e838efcc000e7b30329ed875c329638a U stephan -Z 4928add900897f47fe6d81602626ebaa +Z 2ac71c6aa5db1c4809a7fefefbd39191 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index 025b1b0d2d..77b93bbcf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -10a43cba9bb2c23b5f31b31fcac81be34acec1940cca47d0b8e5a5ccbf1aa8eb \ No newline at end of file +646e7fc3b5ba81c207f013c9a06781986138379f20e787320a811ba3ed5489dc \ No newline at end of file