sociomantic-tsunami / ocean

General purpose, platform-dependent, high-performance library for D
Other
61 stars 56 forks source link

Deprecate in-place deserialization of records with indirections #412

Open mathias-lang-sociomantic opened 6 years ago

mathias-lang-sociomantic commented 6 years ago

Currently, Deserializer has two deserialize methods with the following signatures:

public static Contiguous!(S) deserialize ( S ) ( ref void[] src );
public static Contiguous!(S) deserialize ( S ) ( in void[] src, ref Contiguous!(S) dst )

The former is, AFAIK, unused by any D2-ported app, as this function is tighly coupled with our usage of swarm, which provides us with in char[] buffer in its callbacks. However, there's still a use case for in-place deserialization, when the record has no indirection. Those records are usually small records, and numerous, hence saving on deserialization is desireable.

Hopefully, we can transition to the following (in D2 parlance):

public static Contiguous!(S) deserialize ( S ) ( void[] src ) if (!hasIndirection!(S));
public static Contiguous!(S) deserialize ( S ) ( in void[] src, ref Contiguous!(S) dst )

CC @mihails-strasuns-sociomantic

mihails-strasuns-sociomantic commented 6 years ago

The former is, AFAIK, unused by any D2-ported app

Of what I know it is used at least in MapSerializer and derivatives - and there could be possibly more cases like that, not tied to swarm.

Hopefully, we can transition to the following (in D2 parlance)

Do you mean something like this?

Inout!(S)* deserializeByCast ( S ) ( Inout!(void)[] src )
{
    static assert (!hasIndirections!(S));
    return cast(S*) src.ptr;
}