Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WasmFS] Adds support for large (>4GB) files in OPFS using __i53abi #22561

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

goldwaving
Copy link
Contributor

Currently wasmfs OPFS is limited to 2GB files or smaller. These changes allow working with much larger files by using the __i53abi decorator.

Note that individual reads/writes are still limited to uint32_t block sizes.

@@ -363,6 +367,8 @@ addToLibrary({
wasmfsOPFSProxyFinish(ctx);
},

_wasmfs_opfs_write_access__i53abi: true,
_wasmfs_opfs_write_access__sig: 'iipij',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these sigs should be needed since I believe they are already stored in src/library_sigs.js

Copy link
Contributor Author

@goldwaving goldwaving Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sigs need to be updated. Not sure if those changes have been added to this request. I had to add them for testing, but are not needed once library_sigs.js is updated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, changes to function signatures should be accompanied by the change in library_sigs.js. I normally rebuild using ./test/runner other.test_gen_sig_info --rebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the sigs. Just need to make sure that they are updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should mention that during development when I add a __i53abi decorator to a function in my own library (outside of the emscripten library) and did not have an explicit sig, the implicit sigs would be wrong (in my case it used a BigInt because I had WASM_BIGINT selected). How are the sigs determined at compile/link time?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__sig attributes are pre-calculated for builtin JS libraries (via tools/maint/gen_sig_info.py). For external libraries you need to specifiy the __sig manually, alongside the function.

I made a change recently that will make it impossible to forget to add the __sig when using __i53abi: #22557


// Get the size via an AccessHandle.
void _wasmfs_opfs_get_size_access(em_proxying_ctx* ctx,
int access_id,
off_t* size);

// TODO: return 64-byte off_t.
uint32_t _wasmfs_opfs_get_size_blob(int blob_id);
void _wasmfs_opfs_get_size_blob(int blob_id, off_t* size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't off_t be used as a return type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it can. Not sure if/how i64 values are returned, so I just used the same method as the other get_size function to be safe.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you mark this function as i53abi and j is the return type it should "just work".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. I'll keep that in mind for future updates.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this part of this change? No need to the out parameter then a simple return type will do (IMHO).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this part of this change? No need to the out parameter then a simple return type will do (IMHO).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've change it to return the size directly. Seems to work fine.

Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm % some comments.

Would it be feasible to add a test for this?

@sbc100 sbc100 requested a review from tlively September 11, 2024 18:42
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! LGTM if Sam is happy.

@sbc100 sbc100 changed the title [WASMFS] Adds support for large (>4GB) files in OPFS using __i53abi [WasmFS] Adds support for large (>4GB) files in OPFS using __i53abi Sep 12, 2024
@sbc100
Copy link
Collaborator

sbc100 commented Sep 12, 2024

lgtm, but that do we think about testing this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants