|
Hi, I want to mount My use caseI use https://pglite.dev/ and want to keep FS in RAM, but dump this FS as PGLite have method https://pglite.dev/docs/api#dumpdatadir that even with no compression takes 100ms and this is too long time, since data dump may be called frequently. Since PGLite uses a MEMFS i think the problem is they iterate whole FS content to build archive every time we call dump. As potential solution I see a FS that will store data in single It looks your package implements exactly I need import { configureSingle, fs, SingleBuffer } from "@zenfs/core";
const sharedArrayBuffer = new ArrayBuffer(100000);
await configureSingle({
backend: SingleBuffer,
buffer: sharedArrayBuffer,
});
fs.writeFileSync('/test.txt', 'You can do this anywhere, including browsers!');The problemSo my goal is to
I just read the docs of https://www.npmjs.com/package/@zenfs/emscripten and docs of I see how to create SingleBuffer FS, and I see i can do like that but it's not clear how to mount SingleBuffer FS on EMFS at specific path. Maybe it's just problem with docs. Could you elaborate it |
Replies: 1 comment 8 replies
|
Hey @vitonsky, thanks for reaching out. In this case you want Emscripten to use ZenFS, not the other way around. You should be able to use Emscripten's import { configure, SingleBuffer, InMemory } from '@zenfs/core'
await configure({
mounts: {
'/': {
backend: SingleBuffer,
buffer: new SharedArrayBuffer(1_000_000),
},
'/tmp': InMemory,
},
});Then, tell Emscripten to use emcc ... -lnodefs.js -s NODERAWFS=1Alternatively you can use regular I also looked into the PGLite docs and saw that you can just use node:fs (here). While you can alias |
@james-pre it looks the problem currently on pglite side, I've file an issue to track this problem electric-sql/pglite#810