Replies: 1 comment 3 replies
-
Nice! Congratulations on getting that working, especially with the language barrier. I don't know anything about Rust, but it looks like you're requesting all the blocks from IndexedDB at once to preload memory. That could be the fastest way because it makes the fewest IndexedDB calls, but I'm wondering if it might be faster to fetch a subset of the blocks at a time so you can overlap inserting blocks with fetching blocks (instead of fetching all the blocks before inserting). I don't think it can be dramatically faster because I expect insertion time to be much less than fetch time, but maybe there's a sweet spot where it would be a bit faster. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There is also a related discussion in the previous post: #250.
Inspired by IDBMirrorVFS, I implemented a synchronous version of IDBMirrorVFS in rust. https://github.com/Spxg/sqlite-wasm-rs/blob/master/sqlite-wasm-rs/src/vfs/relaxed_idb.rs.
The principle is to preload the db into memory before xOpen, and then all operations are synchronous. When sqlite calls sync, it asynchronously writes the changed blocks to the indexed db through the indexed transaction. The difference from IDBMirrorVFS is that it does not support
pragma synchronous=full
at all;As for performance, since both reading and writing are done in memory, the performance is good. However, we need to pay attention to the performance of preload the database, because the database is divided into multiple blocks and stored in the indexed db, and it takes some time to read all of them into memory.
I tested the preloading time of 4k, 8k, and 64k on a 1G file (In Macbook Pro m1max). The results are as follows (Different language implementations may differ):
It can be seen that as the size of the block increases, the reading time of each block increases, but as the number of blocks decreases, the overall time also decreases.
Beta Was this translation helpful? Give feedback.
All reactions