[jboss-dev-forums] [Design of JBossCache] - Re: Common marshalling infrastructure

david.lloyd@jboss.com do-not-reply at jboss.com
Fri Mar 27 11:05:09 EDT 2009


"galder.zamarreno at jboss.com" wrote : Yeah, but the problem here is that aftewards, you're treating Primitive Object arrays as serializable and you're not taken advantage of the same performance gains that you applied to primitive arrays.
  | 
  | IOW, in RiverMarshaller.doWriteObject, primitive arrays are treated specially and this is done based on class id coming BASIC_CLASSES. Now, if you don't give the same class IDs or paralell ones to primitive object arrays (Byte[], Integer[]...etc), you're missing out on a performance improvement gain.
  | 
  | Currently, looks to me primitive object arrays would be treated as Serializable.

If you look in RiverMarshaller.doWriteObject() (line 382 in trunk), I check if the object is an array.  If so, the descriptor is written, which consists of a one byte marker (ID_OBJECT_ARRAY_TYPE_CLASS) followed by the component type (which, in the case of the wrapper classes, is treated specially so that's one more byte).

After the descriptor, the array is written which is a sequence of the objects, which in the case of primitive wrapper objects, consists of one type byte (looked up in the type map) followed by the literal value of that wrapper object, or one byte for null.

This isn't quite as speed- and space-efficient as a pure primitive array but it should be pretty darn close.  Also, it means that an Object[] which is filled with, say, Integer instances will take up no more space than an Integer[].  And one byte plus the int value is just about as dense as I can make this, since each value might be null as well.

I don't see how I can really improve on this, unless it's to do something funky like use a bit vector to mark nulls and then pass in the literal values.  But I don't think that'd be worth the gain.


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4221591#4221591

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4221591



More information about the jboss-dev-forums mailing list