mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Micro-optimizations in opfs-sahpool.
FossilOrigin-Name: 52f23db948ae9694df69c00177b85cb569e9b211350a4a2dbf249e7cd8de700c
This commit is contained in:
@@ -35,6 +35,9 @@
|
|||||||
|
|
||||||
https://developer.chrome.com/blog/sync-methods-for-accesshandles/
|
https://developer.chrome.com/blog/sync-methods-for-accesshandles/
|
||||||
|
|
||||||
|
Firefox v111 and Safari 16.4, both released in March 2023, also
|
||||||
|
include this.
|
||||||
|
|
||||||
We cannot change to the sync forms at this point without breaking
|
We cannot change to the sync forms at this point without breaking
|
||||||
clients who use Chrome v104-ish or higher. truncate(), getSize(),
|
clients who use Chrome v104-ish or higher. truncate(), getSize(),
|
||||||
flush(), and close() are now (as of v108) synchronous. Calling them
|
flush(), and close() are now (as of v108) synchronous. Calling them
|
||||||
|
@@ -275,32 +275,33 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
|
|||||||
returns an empty string.
|
returns an empty string.
|
||||||
*/
|
*/
|
||||||
getAssociatedPath: function(sah){
|
getAssociatedPath: function(sah){
|
||||||
const body = this.apBody;
|
sah.read(this.apBody, {at: 0});
|
||||||
sah.read(body, {at: 0});
|
|
||||||
// Delete any unexpected files left over by previous
|
// Delete any unexpected files left over by previous
|
||||||
// untimely errors...
|
// untimely errors...
|
||||||
const dv = new DataView(body.buffer, body.byteOffset);
|
const flags = this.dvBody.getUint32(HEADER_OFFSET_FLAGS);
|
||||||
const flags = dv.getUint32(HEADER_OFFSET_FLAGS);
|
if(this.apBody[0] &&
|
||||||
if(body[0] &&
|
|
||||||
((flags & capi.SQLITE_OPEN_DELETEONCLOSE) ||
|
((flags & capi.SQLITE_OPEN_DELETEONCLOSE) ||
|
||||||
(flags & PERSISTENT_FILE_TYPES)===0)){
|
(flags & PERSISTENT_FILE_TYPES)===0)){
|
||||||
warn(`Removing file with unexpected flags ${flags.toString(16)}`);
|
warn(`Removing file with unexpected flags ${flags.toString(16)}`,
|
||||||
|
this.apBody);
|
||||||
this.setAssociatedPath(sah, '', 0);
|
this.setAssociatedPath(sah, '', 0);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
||||||
sah.read(fileDigest, {at: HEADER_OFFSET_DIGEST});
|
sah.read(fileDigest, {at: HEADER_OFFSET_DIGEST});
|
||||||
const compDigest = this.computeDigest(body);
|
const compDigest = this.computeDigest(this.apBody);
|
||||||
if(fileDigest.every((v,i) => v===compDigest[i])){
|
if(fileDigest.every((v,i) => v===compDigest[i])){
|
||||||
// Valid digest
|
// Valid digest
|
||||||
const pathBytes = body.findIndex((v)=>0===v);
|
const pathBytes = this.apBody.findIndex((v)=>0===v);
|
||||||
if(0===pathBytes){
|
if(0===pathBytes){
|
||||||
// This file is unassociated, so truncate it to avoid
|
// This file is unassociated, so truncate it to avoid
|
||||||
// leaving stale db data laying around.
|
// leaving stale db data laying around.
|
||||||
sah.truncate(HEADER_OFFSET_DATA);
|
sah.truncate(HEADER_OFFSET_DATA);
|
||||||
}
|
}
|
||||||
return this.textDecoder.decode(body.subarray(0,pathBytes));
|
return pathBytes
|
||||||
|
? this.textDecoder.decode(this.apBody.subarray(0,pathBytes))
|
||||||
|
: '';
|
||||||
}else{
|
}else{
|
||||||
// Invalid digest
|
// Invalid digest
|
||||||
warn('Disassociating file with bad digest.');
|
warn('Disassociating file with bad digest.');
|
||||||
@@ -313,17 +314,15 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
|
|||||||
flags into the given SAH.
|
flags into the given SAH.
|
||||||
*/
|
*/
|
||||||
setAssociatedPath: function(sah, path, flags){
|
setAssociatedPath: function(sah, path, flags){
|
||||||
const body = this.apBody;
|
const enc = this.textEncoder.encodeInto(path || '\0', this.apBody);
|
||||||
const enc = this.textEncoder.encodeInto(path, body);
|
|
||||||
if(HEADER_MAX_PATH_SIZE <= enc.written){
|
if(HEADER_MAX_PATH_SIZE <= enc.written){
|
||||||
toss("Path too long:",path);
|
toss("Path too long:",path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const dv = new DataView(body.buffer, body.byteOffset);
|
this.dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
||||||
dv.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
||||||
|
|
||||||
const digest = this.computeDigest(body);
|
const digest = this.computeDigest(this.apBody);
|
||||||
sah.write(body, {at: 0});
|
sah.write(this.apBody, {at: 0});
|
||||||
sah.write(digest, {at: HEADER_OFFSET_DIGEST});
|
sah.write(digest, {at: HEADER_OFFSET_DIGEST});
|
||||||
sah.flush();
|
sah.flush();
|
||||||
|
|
||||||
@@ -414,6 +413,8 @@ sqlite3.installOpfsSAHPoolVfs = async function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
})/*SAHPool*/;
|
})/*SAHPool*/;
|
||||||
|
SAHPool.dvBody =
|
||||||
|
new DataView(SAHPool.apBody.buffer, SAHPool.apBody.byteOffset);
|
||||||
//sqlite3.SAHPool = SAHPool/*only for testing*/;
|
//sqlite3.SAHPool = SAHPool/*only for testing*/;
|
||||||
/**
|
/**
|
||||||
Impls for the sqlite3_io_methods methods. Maintenance reminder:
|
Impls for the sqlite3_io_methods methods. Maintenance reminder:
|
||||||
|
14
manifest
14
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Redefine\swhat\sthe\sopfs-sahpool\sinstallation\spromise\sresolves\sto.\sFix\saddCapacity().\sAdd\sutility\smethods\sto\simport/export\sfiles.
|
C Micro-optimizations\sin\sopfs-sahpool.
|
||||||
D 2023-07-16T10:02:41.870
|
D 2023-07-16T11:49:18.318
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -500,9 +500,9 @@ F ext/wasm/api/sqlite3-api-oo1.js 9678dc4d9a5d39632b6ffe6ea94a023119260815bf32f2
|
|||||||
F ext/wasm/api/sqlite3-api-prologue.js 5dcb5d2d74269545073eec197614b86bd28950132b5fe4de67c10a8a0d5524b2
|
F ext/wasm/api/sqlite3-api-prologue.js 5dcb5d2d74269545073eec197614b86bd28950132b5fe4de67c10a8a0d5524b2
|
||||||
F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b1738645c0134562bb84e88e2fec
|
F ext/wasm/api/sqlite3-api-worker1.js 9f32af64df1a031071912eea7a201557fe39b1738645c0134562bb84e88e2fec
|
||||||
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
|
F ext/wasm/api/sqlite3-license-version-header.js 0c807a421f0187e778dc1078f10d2994b915123c1223fe752b60afdcd1263f89
|
||||||
F ext/wasm/api/sqlite3-opfs-async-proxy.js 961bbc3ccc1fa4e91d6519a96e8811ad7ae60173bd969fee7775dacb6eee1da2
|
F ext/wasm/api/sqlite3-opfs-async-proxy.js 8cf8a897726f14071fae6be6648125162b256dfb4f96555b865dbb7a6b65e379
|
||||||
F ext/wasm/api/sqlite3-v-helper.js e5c202a9ecde9ef818536d3f5faf26c03a1a9f5192b1ddea8bdabf30d75ef487
|
F ext/wasm/api/sqlite3-v-helper.js e5c202a9ecde9ef818536d3f5faf26c03a1a9f5192b1ddea8bdabf30d75ef487
|
||||||
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js 0e982cc4f1b9ed4786086d1115e740b7efd628de5cbaf16caf3a71913f91241b
|
F ext/wasm/api/sqlite3-vfs-opfs-sahpool.js ba799928d945e35c97696005c4911c32f38ba4290168a1fcf0109aea6a2ba19b
|
||||||
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js a5c3195203e6085d7aa89fae4b84cf3f3eec4ff4f928c6d0e5d3ef8b14cbc1c0
|
F ext/wasm/api/sqlite3-vfs-opfs.c-pp.js a5c3195203e6085d7aa89fae4b84cf3f3eec4ff4f928c6d0e5d3ef8b14cbc1c0
|
||||||
F ext/wasm/api/sqlite3-wasm.c 12a096d8e58a0af0589142bae5a3c27a0c7e19846755a1a37d2c206352fbedda
|
F ext/wasm/api/sqlite3-wasm.c 12a096d8e58a0af0589142bae5a3c27a0c7e19846755a1a37d2c206352fbedda
|
||||||
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
|
F ext/wasm/api/sqlite3-worker1-promiser.c-pp.js bc06df0d599e625bde6a10a394e326dc68da9ff07fa5404354580f81566e591f
|
||||||
@@ -2044,8 +2044,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P 279e09070918dab7b60c39179ebb7eb931ca6bd4e589b414f436740499a2f910
|
P 809c6f4de3653ad7a7751af45a7a0d6cb20c3ee3be80c69833c729242227d970
|
||||||
R 3700fe28ac7e053b813d4612e5083eb3
|
R 025c645f0a348eef018e7d822fdbac9d
|
||||||
U stephan
|
U stephan
|
||||||
Z 2285d7e58406d05c66733e55ed60721b
|
Z a785870b274d18ca6df0df66a08dd418
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
@@ -1 +1 @@
|
|||||||
809c6f4de3653ad7a7751af45a7a0d6cb20c3ee3be80c69833c729242227d970
|
52f23db948ae9694df69c00177b85cb569e9b211350a4a2dbf249e7cd8de700c
|
Reference in New Issue
Block a user