3 Replies Latest reply: Feb 15, 2007 3:00 PM by Clebert Suconic RSS

Does JBossSerialization improves performance for Entrnaizabl

santi kumar Newbie

Hi,
In our application we are serializing Externalizable objects. In writeExternal(), we basically converting the data into byte[] and writing them into the streams in writeExternal() and readExternal() methods.

But when we initially call writeObject() and readObject() methods, they are taking much of the CPU cycles.

Can we avoid that overhead if we use JBossSerialization?

THanks
Santi

  • 1. Re: Does JBossSerialization improves performance for Entrnai
    Clebert Suconic Master

    Why do you need to convert your object to bytes inside writeExternal?
    Why not just use the DataOutput to write your data?


    I would need an example to say more than that.

  • 2. Re: Does JBossSerialization improves performance for Entrnai
    santi kumar Newbie

    As the DataOutputStream also writes the primitives by converting them into bytes and writing the bytes into stream, we thought of converting them ahead and writing the byteArray.

    we use some thing like this

    public byte[] convertInt(int value) {
    return new byte[]{
    (byte) (value >>> 24), (byte) (value >>> 16), (byte) (value >>> 8), (byte) (value >>> 0),
    (byte) 0, (byte) 0, (byte) 0, (byte) 0};
    }

    and this byte[] we write into the stream in writeExternal() method.

    public void writeExternal(final ObjectOutput out) throws IOException {
    out.writeInt(this.aData.length);
    out.write(this.aData);
    }



    This Externalizable object is a subclass of another parent object and we serialize that parent object like this.

    PartenObject po = new ParentObject();
    ....setters
    ...


    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);

    objectOutpuStream.writeObject(po);

    But we see much overhead when we call this writeObject() method.

    So are there any optimizations in Jboss Serialization in this redard..



  • 3. Re: Does JBossSerialization improves performance for Entrnai
    Clebert Suconic Master

    I don't think this write(bytes[]) would be any different...

    But you could give it a try with JBoss Serialization to see how it goes.