]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add a test/debug mechanism to shut down the OPFS async listener so that it can be...
authorstephan <stephan@noemail.net>
Tue, 4 Oct 2022 00:54:00 +0000 (00:54 +0000)
committerstephan <stephan@noemail.net>
Tue, 4 Oct 2022 00:54:00 +0000 (00:54 +0000)
FossilOrigin-Name: 7d0bcff4e9b899cd25b393b9f0a02c5dcee2e229f0a0fa01719c7dcd7dcbe7c1

ext/wasm/api/sqlite3-api-opfs.js
ext/wasm/sqlite3-opfs-async-proxy.js
manifest
manifest.uuid

index 42c0e11662c05d82b866fb4c8aea247d559f1712..7b85ac06c83c0ee747212783200aa68afc91f6cd 100644 (file)
@@ -142,7 +142,7 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
                     "\nTotal of",n,"op(s) for",t,
                     "ms (incl. "+w+" ms of waiting on the async side)");
         console.log("Serialization metrics:",metrics.s11n);
-        opRun('async-metrics');
+        W.postMessage({type:'opfs-async-metrics'});
       },
       reset: function(){
         let k;
@@ -285,7 +285,8 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
       state.opIds.xTruncate = i++;
       state.opIds.xWrite = i++;
       state.opIds.mkdir = i++;
-      state.opIds['async-metrics'] = i++;
+      state.opIds['opfs-async-metrics'] = i++;
+      state.opIds['opfs-async-shutdown'] = i++;
       state.sabOP = new SharedArrayBuffer(i * 4/*sizeof int32*/);
       opfsUtil.metrics.reset();
     }
@@ -888,6 +889,20 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
       );
     };
 
+    /**
+       Only for test/development use.
+    */
+    opfsUtil.debug = {
+      asyncShutdown: ()=>{
+        warn("Shutting down OPFS async listener. OPFS will no longer work.");
+        opRun('opfs-async-shutdown');
+      },
+      asyncRestart: ()=>{
+        warn("Attempting to restart OPFS async listener. Might work, might not.");
+        W.postMessage({type: 'opfs-async-restart'});
+      }
+    };
+
     //TODO to support fiddle db upload:
     //opfsUtil.createFile = function(absName, content=undefined){...}
 
@@ -1028,6 +1043,7 @@ const installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri){
             break;
       }
     };
+
   })/*thePromise*/;
   return thePromise;
 }/*installOpfsVfs()*/;
index 0abc3ee2336309a877165136b8c9ee4a9ac48ea9..58bbf79284b2d216b74f0f8055a57b142c58b43f 100644 (file)
@@ -207,18 +207,29 @@ const wTimeEnd = ()=>(
   metrics[waitTimer.op].wait += performance.now() - waitTimer.start
 );
 
+/**
+   Set to true by the 'opfs-async-shutdown' command to quite the wait loop.
+   This is only intended for debugging purposes: we cannot inspect this
+   file's state while the tight waitLoop() is running.
+*/
+let flagAsyncShutdown = false;
+
 /**
    Asynchronous wrappers for sqlite3_vfs and sqlite3_io_methods
    methods. Maintenance reminder: members are in alphabetical order
    to simplify finding them.
 */
 const vfsAsyncImpls = {
-  'async-metrics': async ()=>{
-    mTimeStart('async-metrics');
+  'opfs-async-metrics': async ()=>{
+    mTimeStart('opfs-async-metrics');
     metrics.dump();
-    storeAndNotify('async-metrics', 0);
+    storeAndNotify('opfs-async-metrics', 0);
     mTimeEnd();
   },
+  'opfs-async-shutdown': async ()=>{
+    flagAsyncShutdown = true;
+    storeAndNotify('opfs-async-shutdown', 0);
+  },
   mkdir: async (dirname)=>{
     mTimeStart('mkdir');
     let rc = 0;
@@ -597,7 +608,7 @@ const waitLoop = async function f(){
   const relinquishTime = 1000;
   let lastOpTime = performance.now();
   let now;
-  while(true){
+  while(!flagAsyncShutdown){
     try {
       if('timed-out'===Atomics.wait(
         state.sabOPView, state.opIds.whichOp, 0, waitTime
@@ -669,6 +680,16 @@ navigator.storage.getDirectory().then(function(d){
           waitLoop();
           break;
         }
+        case 'opfs-async-restart':
+          if(flagAsyncShutdown){
+            warn("Restarting after opfs-async-shutdown. Might or might not work.");
+            flagAsyncShutdown = false;
+            waitLoop();
+          }
+          break;
+        case 'opfs-async-metrics':
+          metrics.dump();
+          break;
     }
   };
   wMsg('opfs-async-loaded');
index 3e7ab379526f3f926d1b77c720b78ba7fdb64fe1..53cf33f4a3a9c8029f7722b4a36a2a27363443d4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Set\sdefault\spage\scache\ssize\sto\s16mb\sin\swasm\sbuilds.\sFix\san\soff-by-one\scounter\sin\ssqlite3_wasm_enum_json().\sMinor\scoding\sstyle\sconformance\stweaks.
-D 2022-10-03T23:13:05.622
+C Add\sa\stest/debug\smechanism\sto\sshut\sdown\sthe\sOPFS\sasync\slistener\sso\sthat\sit\scan\sbe\sinspected\s(it\snormally\scan't\sbe\sbecause\sits\stight\sevent-listening\sloop\sties\sup\sthe\sthread)\sand\sthen\srestarted.
+D 2022-10-04T00:54:00.533
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -487,7 +487,7 @@ F ext/wasm/api/pre-js.js 2db711eb637991b383fc6b5c0f3df65ec48a7201e5730e304beba8d
 F ext/wasm/api/sqlite3-api-cleanup.js 5d22d1d3818ecacb23bfa223d5970cd0617d8cdbb48c8bc4bbd463f05b021a99
 F ext/wasm/api/sqlite3-api-glue.js 24a283a49759914f2433b3118865145efbb2f67f52643e445065e02ccecc081b
 F ext/wasm/api/sqlite3-api-oo1.js ac1e08d36bdfb5aa0a2d75b7d4c892fd51819d34c932370c3282810672bcc086
-F ext/wasm/api/sqlite3-api-opfs.js 3d17da752181d67847bd2e3d1f4662df31c5023a1bed5424ebcdeb89770046af
+F ext/wasm/api/sqlite3-api-opfs.js d82870cffef9eef6511c650759c3798b59f10c8338587789abd84be2d9d845c3
 F ext/wasm/api/sqlite3-api-prologue.js 61f28bf7a51479c7b401e2da636b2a0710de77d86f68961445d572a3761dd170
 F ext/wasm/api/sqlite3-api-worker1.js 7f4f46cb6b512a48572d7567233896e6a9c46570c44bdc3d13419730c7c221c8
 F ext/wasm/api/sqlite3-wasi.h 25356084cfe0d40458a902afb465df8c21fc4152c1d0a59b563a3fba59a068f9
@@ -522,7 +522,7 @@ F ext/wasm/speedtest1.html e4cb5d722b494104fc1249e7c008ca018f820a784833c51004c95
 F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
 F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
 F ext/wasm/sql/001-sudoku.sql 35b7cb7239ba5d5f193bc05ec379bcf66891bce6f2a5b3879f2f78d0917299b5
-F ext/wasm/sqlite3-opfs-async-proxy.js 5c6748361f2eb2ee0f2941890917fd9f2d9271de80ec1b65695fb023435b8375
+F ext/wasm/sqlite3-opfs-async-proxy.js 3f8086e543a576a556c17f8ee7c75009fb8e2d3f9bbb9c0de6b9c285dd7f5634
 F ext/wasm/sqlite3-worker1-promiser.js 307d7837420ca6a9d3780dfc81194f1c0715637e6d9540e935514086b96913d8
 F ext/wasm/sqlite3-worker1.js 466e9bd39409ab03f3e00999887aaffc11e95b416e2689596e3d7f1516673fdf
 F ext/wasm/test-opfs-vfs.html eb69dda21eb414b8f5e3f7c1cc0f774103cc9c0f87b2d28a33419e778abfbab5
@@ -2029,8 +2029,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 5b8f8e33afc47c9f0c64dbe34643d7d1c37a0a82afb4656e714a86ef54a9ce6f
-R 9e18661e1500a3e4cdfa05bc23635f3f
+P 72a9e589cc318ec50941739e2edf2c0636284b316c3bf87b71fd363b37619da3
+R b598562b6232b1a22591d878d099e519
 U stephan
-Z e3d9878d6daf198d0150d0ecad381b11
+Z 962cbcc757fdf40c47c3a7056efb3d7c
 # Remove this line to create a well-formed Fossil manifest.
index 3874ec261e712b007c1c1bf7dfd1f1bc20103c24..912cd619c4e592c9580fc6f015cb3873c795cfa2 100644 (file)
@@ -1 +1 @@
-72a9e589cc318ec50941739e2edf2c0636284b316c3bf87b71fd363b37619da3
\ No newline at end of file
+7d0bcff4e9b899cd25b393b9f0a02c5dcee2e229f0a0fa01719c7dcd7dcbe7c1
\ No newline at end of file