Use u64 range instead of usize, for better wasm32 support#6961
Use u64 range instead of usize, for better wasm32 support#6961alamb merged 8 commits intoapache:mainfrom
u64 range instead of usize, for better wasm32 support#6961Conversation
alamb
left a comment
There was a problem hiding this comment.
Thanks @XiangpengHao ❤️
Can you help me understand what currently doesn't work with 32 bit builds now?
We have an existing test for WASM32 that seems to work fine: https://github.com/apache/arrow-rs/actions/runs/12680096825/job/35341184364
I also locally tried checking with an i686 target and that worked fine too 🤔
rustup target add i686-unknown-linux-gnu
cd object_store
cargo check --target=i686-unknown-linux-gnu
...🤔
|
🤔 maybe it is related to wanting to use the http features? But it still seems to compile just fine for me 🤔 |
For anyone following along, the answer is here: #5351 (comment) I still think we should try and add some sort of test that would fail on wasm32 before this change and not after the change. If we don't do that I feel like:
I'll see if I can find some time over the next day or two to help, if no on ebeats me to it |
Thanks for the review @alamb , I agree with the rationale but unfortunately we don't yet have the infra to test wasm32 yet. We currently only build on wasm32, but there's no runner that can actually execute the webassembly |
OpenDAL has an edge test for this; it's worth taking a look. The test code could be found here: https://github.com/apache/opendal/tree/main/core/edge/s3_read_on_wasm |
u64 range instead of usize, for better wasm32 support
alamb
left a comment
There was a problem hiding this comment.
Thank you @XiangpengHao -- I reviewed this PR carefully and I think the API changes are good but there are a few places where going from u64 to usize should be checked (as it could truncate on WASM).
I may be mistaken (my casting knowledge is mostly left over from C/C++ 😅 )
I also have a few other suggestions related to comments, but otherwise this is good to go from my perspectivel
Thank you again for helping push this along
object_store/src/util.rs
Outdated
| fetches.push(range.clone()); | ||
| futures::future::ready(Ok(Bytes::from(src[range].to_vec()))) | ||
| futures::future::ready(Ok(Bytes::from( | ||
| src[range.start as usize..range.end as usize].to_vec(), |
There was a problem hiding this comment.
again, I think we need to check the conversion here rather than truncating
There was a problem hiding this comment.
this function doesn't return error, I just unwrap here, as it's only a test
|
BTW I merged up from main. I also think the obejct_store emulator tests are unrelated to this PR. I have filed To track |
Thank you @Xuanwo -- I didn't see this response before posting my update |
|
I restarted the emulator test to see if it passes: |
|
Now the emulator test is passing after 2 retries: https://github.com/apache/arrow-rs/actions/runs/12770295148/job/35607985446?pr=6961 🤔 |
Co-authored-by: Andrew Lamb <[email protected]>
Co-authored-by: Andrew Lamb <[email protected]>
alamb
left a comment
There was a problem hiding this comment.
Thanks @XiangpengHao -- this looks great to me
|
Thanks again |
…#6961) * u64 ranges * more u64 * make clippy happy * even more u64 * Update object_store/src/lib.rs Co-authored-by: Andrew Lamb <[email protected]> * Update object_store/src/lib.rs Co-authored-by: Andrew Lamb <[email protected]> * address comments --------- Co-authored-by: Andrew Lamb <[email protected]>
…#6961) * u64 ranges * more u64 * make clippy happy * even more u64 * Update object_store/src/lib.rs Co-authored-by: Andrew Lamb <[email protected]> * Update object_store/src/lib.rs Co-authored-by: Andrew Lamb <[email protected]> * address comments --------- Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
usizewithu64#5351Rationale for this change
Ranges should be u64 so that 32 bit platforms can read files larger than 4GB. More details can be found in #5351
What changes are included in this PR?
This is a rather simple change. No functionality change for 64 bit platforms. But is a breaking change for trait implementors.
Given that we already break one in #6619, it's seems like a good timing to also include this change.
This PR added and removed a few casting. I have checked the casting is ok, but please help me check again.
My principle of using
usizevsu64:usize, e.g., slicing a memory rangeu64Are there any user-facing changes?