Compile to JavaScript? #164
Replies: 5 comments 9 replies
-
I'm sure it isn't as simple as setting the |
Beta Was this translation helpful? Give feedback.
-
An alternative is to rewrite the VFS in wasm so that someone could ostensibly stay inside of wasm for direct database calls, if they were willing to write their own side in wasm. The persistence aspect would still cross the boundary but since persistence is asynchronous the more noticeable aspect of speed is crossing the boundary during userspace calls to the library. |
Beta Was this translation helpful? Give feedback.
-
FWIW, within the sqlite project, the single biggest performance hit for a JS-side VFS is not entering and leaving WASM but is in the coordination of making the async storage behave synchronously for the sqlite3_vfs API. We could more than double the performance, very conservatively speaking, if the OPFS storage API was fully synchronous. (We know this for reasons too verbose to go into on this mobile device's keyboard.) |
Beta Was this translation helpful? Give feedback.
-
I completely agree with @sgbeal, we are all holding are breath and hoping the browser gods will give us fully sync OPFS apis in workers 🙏 On @KyleAMathews nudge I'm reposting my comment from our discord below. -- https://discord.com/channels/933657521581858818/1212676471588520006/1222822993034477668 Hey, yep, I've had exactly the same thoughts. A "JS native" sql database would be super interesting as all types could be maintained in their native format in memory. No marshalling or serialising needed. However, I think the main performance bottle necks in both SQLite and PGlite are not in the marshalling/serialising. The keys ones to look at are:
|
Beta Was this translation helpful? Give feedback.
-
Hi @samwillis! excited about this pglite project you have going on. But when are any of these db in the browser projects going to give me my Rust hooks 😭. If nothing else, the devex of interacting with the sqlite c api and doing all the caching of prepared statements would be so much nicer if I could just have it in 🦀. |
Beta Was this translation helpful? Give feedback.
-
I'm curious if anyone has tried compiling SQLite to JavaScript instead of wasm? It seems much of the cost of calls is traversing the js/wasm bridge so if SQLite was just js, it might be faster.
Beta Was this translation helpful? Give feedback.
All reactions