Postgres WASM
71–80 of 190 posts
Re: Postgres WASM
#72The first thing to point out is that our implementation isn't pure WASM. We attempted to compile Postgres for WASM directly from source, but it was more complicated that we anticipated. Crunchy's HN post provided some hints about the approach they took, which was to virtualize a machine in the browser. We pursued this strategy too, settling on v86 which emulates an x86-compatible CPU and hardware in the browser. I’m…
For example, for just one of many hairy problems, consider that Postgres uses global variables in each backend for backend-local state (global state as such is in shared memory). How does this look in assembly, accounting for both the kernel and userspace components? This is the problem.
A general way to convey this is: the more system calls a piece of software uses, the more difficult a WASM target without architecture emulation becomes. And Postgres doesn't even obligate that many obscure ones.
Re: Postgres WASM
#73Re: Postgres WASM
#74Hint: Don't use ctrl-w in their terminal. Turns out that has another meaning in Firefox... [EDIT]: I'm zero for three thus far. I give up.
The key combo still appears to be intercepted, as the menu flashes but it doesn't close the tab. So I doubt you can use it in the terminal, but at least you won't lose your work.
If you pin the tab but not in its own window, ctrl-W doesn't close the tab but it does switch to another tab.
Source for the first point: https://www.reddit.com/r/firefox/comments/rs2bhn/comment/hqn... The rest is from me trying things out just now on MacOS, where really I used cmd-W, because ctrl-W doesn't do anything on MacOS. I'm assuming the corresponding behaviours will apply to ctrl-W on Windows and Linux, but you should test before relying on this.
Re: Postgres WASM
#75Re: Postgres WASM
#76Completely naive question here, but could you cluster the WASM instances (with mods, I'd assume, more is it possible via the WASM abstractions?). Not sure why but seems like a interesting thing :)
Re: Postgres WASM
#77Earlier quoted context omitted.
One that performs way worse then existing container solutions but that will of course be used to distribute binary blobs.
Agree, it is much slower. I would be interesting to see a comparison between a full recompiled version running on top of a wasm runtime vs some container solution but seems they found a lot of problems recompiling it.
Re: Postgres WASM
#78Earlier quoted context omitted.
Could I hypothetically pass USB through to v86? Like libusb on the host into v86 on the guest? Or do USB over IP or something?
Chrome supports a USB api that could potentially work for that, https://developer.chrome.com/docs/extensions/reference/usb/ sadly though it's chrome only, not a standard of any kind (no other browsers support it that I know of). ESPHome can use it to program microcontrollers (along with the serial port support).
Classic Google...
Re: Postgres WASM
#79Earlier quoted context omitted.
Could I hypothetically pass USB through to v86? Like libusb on the host into v86 on the guest? Or do USB over IP or something?
Chrome supports a USB api that could potentially work for that, https://developer.chrome.com/docs/extensions/reference/usb/ sadly though it's chrome only, not a standard of any kind (no other browsers support it that I know of). ESPHome can use it to program microcontrollers (along with the serial port support).
Re: Postgres WASM
#80Earlier quoted context omitted.
Supabase developer here. I've used this to move data from a live Supabase database down to the browser for testing and playing around with things in a "sandbox" environment. Then I save snapshots along the way in case I mess things up. To move a table over from my Supabase-hosted postgres instance to the browser, I just exit out of psql and run something like this: pg_dump --clean --if-exists --quote-all-identifiers…
Correct me if I'm wrong, but given your profile (I assume someone in the tech world), nothing stopping you from doing all of the above with a local pg. If installing is annoying you could run it in docker.