Orange 1.0.0 beta - serialization library

Robert Jacques sandford at jhu.edu
Wed Aug 24 07:36:17 PDT 2011


On Wed, 24 Aug 2011 02:25:19 -0400, Jacob Carlborg <doob at me.com> wrote:

> On 2011-08-24 02:53, Michel Fortin wrote:
>> On 2011-08-23 06:51:57 +0000, Jacob Carlborg <doob at me.com> said:
>>
>>> On 2011-08-22 21:50, Vladimir Panteleev wrote:
>>>> On Sat, 20 Aug 2011 18:13:32 +0300, Jacob Carlborg <doob at me.com> wrote:
>>>>
>>>>> I've almost finished the rewrite of my serialization library Orange.
>>>>
>>>> While I've never had the chance to use Orange myself, one of the
>>>> problems I've often heard being associated with using Orange was large
>>>> binary file sizes. What are your thoughts about this issue? If this is a
>>>> real problem, do you think the toolchain could be improved in this
>>>> regard (perhaps ideas such as merging bitwise-identical functions at
>>>> link time)?
>>>
>>> I never heard anything being associated with using Orange. The library
>>> takes up 77.8 kb, compiled with dmd 1.067 on Mac OS X. A Hello World
>>> app using Orange takes up 1.2 mb, I don't know if that's a problem.
>>>
>>> I don't have any thoughts, I didn't know it was an issue. Yes I think
>>> the tool chain can be improved, at least I hope it can.
>>
>> If there's any truth in that (which I don't know), it'd probably have
>> something to do with the amount of generated code through templates.
>>
>> When I was still developing the D/Objective-C bridge as a bunch of
>> templates and stub objects, the binary size was growing significantly
>> for each new Objective-C class I added (due to the insane number of stub
>> functions instantiated). And at some point it became totally impractical
>> to use, even though it worked.
>
> Yeah, that was insane.
>
>> I doubt this is a problem for Orange because of its more limited scope,
>> but it'd nevertheless be wise to measure how much the binary size grows
>> when you add more types to serialize and unserialize and more code is
>> generated as a result.
>
> I guess I should try serializing a big data structure of some kind.
>

Actually, it's the number of types rather than the amount of memory which causes issues. You can try something like this:

     template Qual(T) {
         alias TypeTuple!(T,T[],const(T)[],immutable(T)[],shared(T)[], const T, immutable T, shared T, const T[], immutable T[], shared T[]) Qual;
     }
     alias TypeTuple!(bool,ubyte,byte,ushort,short,uint,int,ulong,long,float,double,real,char,wchar,dchar) ValueTypes;

     alias staticMap!(Qual,ValueTypes) QualifiedTypes;

To generate a large tuple of all the basic D types and then see how much code is generated.


More information about the Digitalmars-d-announce mailing list