]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
speedtest1.js: only install opfs-sahpool if it's provided via --vfs flag, to avoid...
authorstephan <stephan@noemail.net>
Sun, 16 Jul 2023 14:07:59 +0000 (14:07 +0000)
committerstephan <stephan@noemail.net>
Sun, 16 Jul 2023 14:07:59 +0000 (14:07 +0000)
FossilOrigin-Name: aa94c8abfbdfc4c7b36554c4b3ea90a5065e7e3f4294c64c8cbf688b4688300d

ext/wasm/api/sqlite3-vfs-opfs-sahpool.js
ext/wasm/speedtest1-worker.js
manifest
manifest.uuid

index 163544f91572d2ba7964dc006ee3741ca587fc21..d40581aba30aaba35111521d29a9e1c4b0e43197 100644 (file)
@@ -689,6 +689,12 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
   PoolUtil.reduceCapacity = async (n)=>SAHPool.reduceCapacity(n);
   PoolUtil.getCapacity = SAHPool.getCapacity.bind(SAHPool);
   PoolUtil.getActiveFileCount = SAHPool.getFileCount.bind(SAHPool);
+  /** If capacity is < min, increase capacity to min, else do
+      nothing. Resolves to the new capacity. */
+  PoolUtil.reserveMinimumCapacity = async (min)=>{
+    const c = SAHPool.getCapacity();
+    return (c < min) ? SAHPool.addCapacity(min - c) : c;
+  };
   /**
      Synchronously reads the contents of the given file into a
      Uint8Array and returns it. This will throw if the given name is
index 6cd0c1af000f9ee3c562729604c72843bedb0657..c2bf37b8312331e3330bff3939d50288477e49c4 100644 (file)
@@ -48,7 +48,7 @@
   const log = (...args)=>logMsg('stdout',args);
   const logErr = (...args)=>logMsg('stderr',args);
 
-  const runSpeedtest = function(cliFlagsArray){
+  const runSpeedtest = async function(cliFlagsArray){
     const scope = App.wasm.scopedAllocPush();
     const dbFile = App.pDir+"/speedtest1.sqlite3";
     try{
       ];
       App.logBuffer.length = 0;
       mPost('run-start', [...argv]);
+      if(App.sqlite3.installOpfsSAHPoolVfs
+         && !App.sqlite3.$SAHPoolUtil
+         && cliFlagsArray.indexOf('opfs-sahpool')>=0){
+        log("Installing opfs-sahpool...");
+        await App.sqlite3.installOpfsSAHPoolVfs().then(PoolUtil=>{
+          log("opfs-sahpool successfully installed.");
+          App.sqlite3.$SAHPoolUtil = PoolUtil;
+        });
+      }
       App.wasm.xCall('wasm_main', argv.length,
                      App.wasm.scopedAllocMainArgv(argv));
     }catch(e){
     msg = msg.data;
     switch(msg.type){
         case 'run':
-          try {
-            runSpeedtest(msg.data || []);
-          }catch(e){
-            mPost('error',e);
-          }
+          runSpeedtest(msg.data || [])
+            .catch(e=>mPost('error',e));
           break;
         default:
           logErr("Unhandled worker message type:",msg.type);
   };
   log("Initializing speedtest1 module...");
   self.sqlite3InitModule(EmscriptenModule).then(async (sqlite3)=>{
-    const S = globalThis.S = sqlite3;
+    const S = globalThis.S = App.sqlite3 = sqlite3;
     log("Loaded speedtest1 module. Setting up...");
-    if(S.installOpfsSAHPoolVfs){
-      await S.installOpfsSAHPoolVfs().then(P=>{
-        S.SAHPoolUtil = P;
-        //return P.addCapacity(5).then(log("pool capacity:",P.getCapacity()));;
-      }).catch(e=>{
-        logErr("Error setting up opfs-sahpool:",e.message);
-      });
-    }
     App.vfsUnlink = function(pDb, fname){
       const pVfs = S.wasm.sqlite3_wasm_db_vfs(pDb, 0);
       if(pVfs) S.wasm.sqlite3_wasm_vfs_unlink(pVfs, fname||0);
index 3cf5646d7ccec0d0d7107893dbab762fa96dd635..d2e88ef2acae47977783b040232c77081be8be32 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C During\s"opfs"\sVFS\sinit,\scheck\sfor\sURL\sparam\sopfs-disable\sand,\sif\sset,\sdo\snot\sinstall\sthe\sVFS.\sAdded\sper\sforum\ssuggestion\sto\sprovide\sa\sway\sto\shelp\srule\sout\smisinteraction\sbetween\sthe\s"opfs"\sand\s"opfs-sahpool"\sVFSes.
-D 2023-07-16T12:02:37.445
+C speedtest1.js:\sonly\sinstall\sopfs-sahpool\sif\sit's\sprovided\svia\s--vfs\sflag,\sto\savoid\slocking\serrors\sin\sconcurrent\sspeedtest1\stabs\swith\sother\sVFSes.\sAdd\sopfs-sahpool\sreserveMinimumCapacity().
+D 2023-07-16T14:07:59.930
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -502,7 +502,7 @@ F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b17386
 F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
 F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
 F ext/wasm/api/sqlite3-v-helper.js e5c202a9ecde9ef818536d3f5faf26c03a1a9f5192b1ddea8bdabf30d75ef487
-F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js ba799928d945e35c97696005c4911c32f38ba4290168a1fcf0109aea6a2ba19b
+F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js 5ffed44d7bac1b4038e1505ffc7ab63e82726a97a64193ddbd5b414722f0808b
 F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js 842d55b35a871ee5483cc5e0cf067a968362b4d61321f08c71aab5505c72f556
 F ext/wasm/api/sqlite3-wasm.c 12a096d8e58a0af0589142bae5a3c27a0c7e19846755a1a37d2c206352fbedda
 F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
@@ -540,7 +540,7 @@ F ext/wasm/scratchpad-wasmfs.mjs 66034b9256b218de59248aad796760a1584c1dd84223150
 F ext/wasm/speedtest1-wasmfs.html 0e9d335a9b5b5fafe6e1bc8dc0f0ca7e22e6eb916682a2d7c36218bb7d67379d
 F ext/wasm/speedtest1-wasmfs.mjs ac5cadbf4ffe69e9eaac8b45e8523f030521e02bb67d654c6eb5236d9c456cbe
 F ext/wasm/speedtest1-worker.html e33e2064bda572c0c3ebaec7306c35aa758d9d27e245d67e807f8cc4a9351cc5
-F ext/wasm/speedtest1-worker.js faa4a06ec21921aaa0e0b672a94b56037da837e16732bdd6545b99f1cadbb32e
+F ext/wasm/speedtest1-worker.js cda2f6cf0a6b864d82e51b9e4dfd1dfb0c4024987c5d94a81cc587e07acc9be4
 F ext/wasm/speedtest1.html ff048b4a623aa192e83e143e48f1ce2a899846dd42c023fdedc8772b6e3f07da
 F ext/wasm/split-speedtest1-script.sh a3e271938d4d14ee49105eb05567c6a69ba4c1f1293583ad5af0cd3a3779e205 x
 F ext/wasm/sql/000-mandelbrot.sql 775337a4b80938ac8146aedf88808282f04d02d983d82675bd63d9c2d97a15f0
@@ -2044,8 +2044,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 52f23db948ae9694df69c00177b85cb569e9b211350a4a2dbf249e7cd8de700c
-R e0c8363b212a784e3aba23833aa919e5
+P 29905b7a75b73e32125bf9116033cae7235a135b668a3b783a3d8dcb0bc80374
+R 04e7987eb127f55eddff193be36455e6
 U stephan
-Z 6a5be95b2a13778a907aeca05fd3977d
+Z 53c8cb4a4900e0bba3854b3011d70f79
 # Remove this line to create a well-formed Fossil manifest.
index 24fb7ae1c32f1633bc9e5e7f13440ae4db5348e4..c9034b92fd685ead49141250a9b2e47a4381f8a5 100644 (file)
@@ -1 +1 @@
-29905b7a75b73e32125bf9116033cae7235a135b668a3b783a3d8dcb0bc80374
\ No newline at end of file
+aa94c8abfbdfc4c7b36554c4b3ea90a5065e7e3f4294c64c8cbf688b4688300d
\ No newline at end of file