Add ε-serde support (no change to the code)#181
Conversation
|
Thanks for sending this PR! e-serde sounds really cool, but in terms of adding support into
The rkyv folks, have, I think, figured out how to deal with this. I think they tried adding support to crates like you're doing here, but that didn't work out.
To clarify here, |
More than thirty years ago I've been exactly in your position (on the other side), so I understand it perfectly. That's not an issue—we can just remove (and maybe add MIT—Rust projects seems to be mostly MIT + Apache).
Well... let's say it has been complicated 😂. I don't think that's true tho, unless you want to use it for archival purposes, which was never one of our goals. There has been just one change to the major version of the file format, which I think is more relevant for a serialization framework.
I think this is kind of apple-and-oranges, as rkyv gives you back a different type, and that type is likely bound to the version of rkyv. That's exactly what we wanted to avoid: when you deserialize with zero-copy aliasing, or you do memory mapping, we give you back your own type, not another one. The version just depends on your crate, not on ours.
I know what |
|
|
Oh well, yes, you're right—I wasn't thinking of that, even if it actually happened to me with other crates. |
This PR adds gated ε-serde support to
fst. There is no change in thefstcode—just a few gated derives and implementations.ε-serde tries to solve in general the problem
fstsolves specifically for memory-mapping large amount of data, but it does it using derive macros for generic data structures; it replaces recursively vectors or boxed slices with reference to a byte buffer (e.g., memory-mapped) and strings with references tostr.The additional feature gained by
fstis the possibility of serializing and map into memory directly any hierarchical combination of types, not just leaves (there are a few examples and the end oftest.rs.fstwas in fact the trigger for expanding the scope of ε-serde: originally, we were just replacing type parameters which where the type of a field; now, we replace them recursively everywhere (which turned out to be fairly complicated).This PR does not modify any
fstcode, but because of that it needs to provide hand-made serialization/deserialization implementations for the leaves (Str,Subsequence) because we can only support memory mapping, and not full deserialization.We are also proposing another PR that just uses gated derives, but in this case we need to add a parameter to
StrandSubsequence, so that it can be substituted. We gain full deserialization, which is of interest as ε-serde can fully deserialize into transparent huge pages, which might provide some performance boost. But this requires a small incompatible change to the exposed API.