4 ms·
> OPFS doesn’t come with graceful handling of concurrency out of the box. Developers should be aware of this and design around it. There's a multiple readers a
by AlexErrant 2y ago
> OPFS doesn’t come with graceful handling of concurrency out of the box. Developers should be aware of this and design around it.
There's a multiple readers and writers proposal [0]. It's been "position: positive" by Firefox [1], implemented in Chrome [2], and ignored by Webkit [3] (of course).
0: https://github.com/whatwg/fs/blob/main/proposals/MultipleReadersWriters.md
1: https://github.com/mozilla/standards-positions/issues/861
2: https://chromestatus.com/feature/5172892632875008
3: https://github.com/WebKit/standards-positions/issues/238
Love the shoutout to Roy Hashimoto. He's been writing VFSs for SQLite-on-the-browser and perf testing them. He's recently wrote "IDBMirrorVFS", which "is a new example VFS that keeps all SQLite files in memory while persisting to IndexedDB". It has remarkable performance, of course. https://github.com/rhashimoto/wa-sqlite/discussions/189 https://github.com/rhashimoto/wa-sqlite/discussions/189
Also, looks like Roy takes advantage of the aforementioned proposal when he wrote `OPFSPermutedVFS`, which takes 2nd pace behind `IDBMirrorVFS` w/r/t perf. https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/README.md#opfspermutedvfs https://github.com/rhashimoto/wa-sqlite/blob/master/src/exam...
- jauntywundrkind 2y agoIt sucks that even the newest make-wadm-sqlite-fast FileAccessHandles are still an intermediated virtual file system hosted by the browser. I don't get why we have three different file system APIs on the web and none that just use files. Meanwhile WASI has their own server-side file system APIs but neither WASI nor the browser side seem to have any effort to get on the same page. It'll be 2035 before component-model ends up being usable on the web, at this rate, before modules are modular.
- jitl 2y agoThe profusion of underpowered interfaces is frustrating but I don't see how browsers could "just use files" What does this mean? Providing the POSIX filesystem C language APIs with file descriptor numbers, etc? I guess the browser makers could go Cosmopolitan-C style and emulate the Linux filesystem interface on all platforms, but I think you'd find there's still a weird intermediary layer in between your code and the underlying OS filesystem. Even on Linux the browser would have a virtual filesystem to provide sandboxing & quality-of-service governance. On other systems you'd need a virtual filesystem to paper over those differences between operating systems. Windows exists!
- jauntywundrkind 2y agoMingw has been paving over the differences for years. Node.js paves over them, makes windows look very posix'y. I'm tired of Windows being an excuse, a forever dragging boat anchor, a lower than low denominator that justifies doing shitty jobs. Keep the current virtualized file system for Windows that's fine, but man, we should stop designing specs, setting the future to keep targeting the dirty distant sad past. And we have decades of experiences (mingw) showing that we can polyfill a good platform atop the big bad no good windows Boogeyman. It just feels like the make excuse for bad camp has been in charge of our spiritual direction for 25 years here & it's never gotten us anywhere. It's always pretty shitty. I struggle to believe these protestations against doing the natural good thing help. We should 100% just triple down on trying, on bringing WASI forward.
- pjc50 2y agoThe one thing you do NOT want to let websites have access to is files.
- jauntywundrkind 2y agoI don't see why Origin Private File System needs some fully virtualized nonsense. You can just create some fuck off far out directory for the site for this cause. Should be fine. There's already pretty safe secure & altogether sensible options for giving websites access to files. Alas it's all via even slower even worse abominations that File Access Handles, because spec authors swear it would be hell on earth if they didn't quintuple buffer every read or write, will swear we could never ever trust devs to ever possibly do a good thing. There's been such a constant hedging that being slow & adding layers of safety to io is necessary and it's taken literally decades to get even these crap ass concessions. I know this is impolite and I'm sorry but what cowardice, what unrelenting sad clutching of pearls. What utter betrayal of Extensibile Web Manifesto. https://github.com/extensibleweb/manifesto https://github.com/extensibleweb/manifesto