-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Serialization of bitstype Array is not cross-platform #11135
Comments
I'd agree on your ideas to fix this... I think cross-platform serialization could be important |
@ScottPJones Yes, see https://github.com/timholy/HDF5.jl But please use the mailing list for general questions, to keep GitHub issues focused. |
probably a good idea. the current implementation of the serializer pretends to be stateless, so that would need to change first. (searching the github issues list should come up with a few related issues) |
You could also use a staged function to generate efficient code when offsets are not the same. This is basically the approach we take in JLD, where we currently pack everything on disk. Of course the tradeoff is codegen time vs. execution time. |
Has this actually caused a problem, or is it just theoretical at the moment? I think it is way too complicated to include a header and force all consumers to handle all possible formats. We should have one standard format instead, e.g. make x86_64 the official format, or require alignment padding to be removed (always something to be said for sending as few bytes as possible). |
There have been real JLD issues raised on this. JuliaIO/HDF5.jl#209 and a few others. If we pick a standard format then we need to at least teach every platform to write to it correctly. Maybe somewhat easier than teaching every platform to read every other format correctly. |
@tkelman The problem there is not the ABI (which is not a problem for JLD, because we store everything packed), but that, if a type has an Int field, the type itself differs between 32-bit and 64-bit systems. Handling those kinds of conversion definitely requires type metadata and is important for a data interchange format, but I'm not sure it's within the scope of |
I think it would be nice to handle |
Since we use the base serializer for multiprocess communication, it is also a performance concern since it should be a lot faster (or at least easier to optimize ?) to emit a bits array in native format. In theory we should be able to bring that down to zero-copy by using platform specific stuff ? It may be easier to have it configurable with some flags (compact/crossplatform/fast/...). But well, this is all vapor until someone steps up and implement something :-) |
@JeffBezanson I'd dealt with this a long time ago, and simply packed integers (and scaled decimals and floats), by removing 0s (or 0xffs for negative #s), the output was always little-endian, each value had an indication of it's length... very good for storage, also very compact for transmission (in the days when the "network" could be just a serial line), no need for header... however, not so fast for multiprocess communication (but then, you wouldn't have a cross-platform issue anyway). |
Yes I think we should use a format like that. So far the serializer has only targeted homogeneous clusters. Actually the serializer is already very close to being able to support mismatched |
See also #1295 |
Moving this off the 1.0 milestone. The 1.0 stability guarantee need not cover the serialization format. What we should do however is add a version number header, so we can at least detect compatibility. |
Cross ref #7909 |
Wow, didn't expect this issue to be that long-standing! Can this reasonably be fixed? Presumably, it not only affects explicit serialization, but also running |
wow this is awful. It's definitely fixable, it just likely would be a pain. I think this is one where everyone forgot about it in the rush to 1.0 and never picked it back up. |
for a possible smaller MWE, does |
|
that's very odd then.
reproduce the issue? I am having some trouble figuring out what the difference in representation is. They should have the same size, and same padding (unless the alignment is different?). @vtjnash do you know what would cause this issue to appear for this example? |
I am not sure. I think the new reinterpret code might help though, since it knows how to remove padding bytes. Some type sizes might still be different, but it may reduce the differences. |
So, fails when sizes are different I guess. |
ok, that makes a tiny bit of sense. So the difference is where in the union the smaller value is being put. |
Serializing a bitstype array is done by copying the memory directly, however the field offsets are set to conform to the local C ABI.
What we should probably do :
The text was updated successfully, but these errors were encountered: