diff options
author | stephan <stephan@noemail.net> | 2022-09-19 18:22:29 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2022-09-19 18:22:29 +0000 |
commit | aec046a2642b391b9ded1f117b81860de679d605 (patch) | |
tree | 3b45b489b0f09a3a8a9c0c887ebbb652d611cf61 /ext/wasm/api/sqlite3-api-opfs.js | |
parent | f815011a085e86117da3e28f8281fb13cf1bcdf9 (diff) | |
download | sqlite-aec046a2642b391b9ded1f117b81860de679d605.tar.gz sqlite-aec046a2642b391b9ded1f117b81860de679d605.zip |
Further metrics and buffer-copy optimizations in the OPFS proxy, but with little effect.
FossilOrigin-Name: d1f1fe6f1c60640f7770dfb9245c459a09b8d24ec2ddf664dff77c810bd51f96
Diffstat (limited to 'ext/wasm/api/sqlite3-api-opfs.js')
-rw-r--r-- | ext/wasm/api/sqlite3-api-opfs.js | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/ext/wasm/api/sqlite3-api-opfs.js b/ext/wasm/api/sqlite3-api-opfs.js index b7e6887f6..3fd08d9ae 100644 --- a/ext/wasm/api/sqlite3-api-opfs.js +++ b/ext/wasm/api/sqlite3-api-opfs.js @@ -140,16 +140,19 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) */ opfsUtil.metrics = { dump: function(){ - let k, n = 0, t = 0; - for(k in metrics){ + let k, n = 0, t = 0, w = 0; + for(k in state.opIds){ const m = metrics[k]; n += m.count; t += m.time; + w += m.wait; m.avgTime = (m.count && m.time) ? (m.time / m.count) : 0; m.avgWait = (m.count && m.wait) ? (m.wait / m.count) : 0; } - console.log("metrics for",self.location.href,":",metrics, - "\nTotal of",n,"op(s) for",t,"ms"); + console.log(self.location.href, + "metrics for",self.location.href,":",metrics, + "\nTotal of",n,"op(s) for",t, + "ms (incl. "+w+" ms of waiting on the async side)"); }, reset: function(){ let k; @@ -157,9 +160,9 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) for(k in state.opIds){ r(metrics[k] = Object.create(null)); } - [ // timed routines which are not in state.opIds - 'xFileControl' - ].forEach((k)=>r(metrics[k] = Object.create(null))); + //[ // timed routines which are not in state.opIds + // 'xFileControl' + //].forEach((k)=>r(metrics[k] = Object.create(null))); } }/*metrics*/; @@ -209,6 +212,7 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) state.opIds.xWrite = i++; state.opIds.mkdir = i++; state.opSAB = new SharedArrayBuffer(i * 4/*sizeof int32*/); + state.opIds.xFileControl = state.opIds.xSync /* special case */; opfsUtil.metrics.reset(); } @@ -413,18 +417,20 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) }, xFileControl: function(pFile, opId, pArg){ mTimeStart('xFileControl'); - if(capi.SQLITE_FCNTL_SYNC===opId){ - return opRun('xSync', {fid:pFile, flags:0}); - } + const rc = (capi.SQLITE_FCNTL_SYNC===opId) + ? opRun('xSync', {fid:pFile, flags:0}) + : capi.SQLITE_NOTFOUND; mTimeEnd(); - return capi.SQLITE_NOTFOUND; + return rc; }, xFileSize: function(pFile,pSz64){ mTimeStart('xFileSize'); const rc = opRun('xFileSize', pFile); if(!isWorkerErrCode(rc)){ - const f = __openFiles[pFile]; - wasm.setMemValue(pSz64, f.sabViewFileSize.getBigInt64(0,true) ,'i64'); + wasm.setMemValue( + pSz64, __openFiles[pFile].sabViewFileSize.getBigInt64(0,true), + 'i64' + ); } mTimeEnd(); return rc; @@ -454,6 +460,7 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) return rc; }, xSync: function(pFile,flags){ + ++metrics.xSync.count; return 0; // impl'd in xFileControl(). opRun('xSync', {fid:pFile, flags}); }, xTruncate: function(pFile,sz64){ @@ -492,8 +499,9 @@ sqlite3.installOpfsVfs = function callee(asyncProxyUri = callee.defaultProxyUri) const vfsSyncWrappers = { xAccess: function(pVfs,zName,flags,pOut){ mTimeStart('xAccess'); - const rc = opRun('xAccess', wasm.cstringToJs(zName)); - wasm.setMemValue(pOut, rc ? 0 : 1, 'i32'); + wasm.setMemValue( + pOut, (opRun('xAccess', wasm.cstringToJs(zName)) ? 0 : 1), 'i32' + ); mTimeEnd(); return 0; }, |