You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Igor Vaynberg <ig...@gmail.com> on 2007/01/30 07:01:16 UTC

removing that pesky transient boolean attached from detachable models

jonathan and i have been brainstorming about removing private transient
boolean attached=false from our detachable models, and after an hour here is
what we came up with (see attachment). i know we use some custom
serialization for models, etc so do you guys this is going to interfere with
that? it almost seems too simple so i am a bit suspicious. if it works out
it should save a fair bit of memory.

one thing i know it will "break" is terracotta, it will need extra config to
replicate what we do in readobject()

-igor

Re: removing that pesky transient boolean attached from detachable models

Posted by Eelco Hillenius <ee...@gmail.com>.
> Terracotta is very interested in maintaining compatibility with
> Wicket (it's an explicit callout in the requirements for our next
> release).  I wonder if there's some way we can play nicely together...

We want to maintain compatibility as well, and discussed this a bit on IRC.

I think what we should do is anytime we potentially break things for
Terracotta, we should open up a JIRA issue so that at least it is
known and so that either people from Wicket or Terracotta can suggest
fixes.

And if you have suggestions right now that will make it easier to
break such fixes, that would be very welcome.

Eelco

Re: removing that pesky transient boolean attached from detachable models

Posted by Orion Letizi <or...@terracottatech.com>.
As you probably know, Terracotta doesn't execute the readObject()  
method when it hydrates an object onto a cluster node.  This is  
because it doesn't use Java serialization to move object data around,  
so the context of the readObject() call (i.e., the ObjectInputStream  
argument) is difficult/impossible to create (I can't think of a way  
to do it, anyway...).

Terracotta provides two mechanisms for re-establishing local-JVM  
object state: 1) declaring a method to call on object hydration and  
2) writing bean shell code to be executed on object hydration.

One way to ameliorate incompatibility issues is to extract any  
transient field initialization code that doesn't rely on the  
ObjectInputStream out of the readObject() method to another method.   
That way, you can configure Terracotta to call that method on object  
hydration.

I've spent a little time looking through the Wicket code in trunk,  
but I haven't seen many opportunities to take advantage of this  
approach.  There seems to be a fair amount of custom serialization  
code in the write/readObject() methods that write to and read from  
the object streams directly.  But, I'm not that familiar with the code.

Terracotta is very interested in maintaining compatibility with  
Wicket (it's an explicit callout in the requirements for our next  
release).  I wonder if there's some way we can play nicely together...

--Orion

> On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
>>
>> jonathan and i have been brainstorming about removing private  
>> transient
>> boolean attached=false from our detachable models, and after an  
>> hour here is
>> what we came up with (see attachment). i know we use some custom
>> serialization for models, etc so do you guys this is going to  
>> interfere with
>> that? it almost seems too simple so i am a bit suspicious. if it  
>> works out
>> it should save a fair bit of memory.
>>
>> one thing i know it will "break" is terracotta, it will need extra  
>> config
>> to replicate what we do in readobject()
>>
>> -igor
>>
>>
>>
>>
>>


Re: removing that pesky transient boolean attached from detachable models

Posted by Jonathan Locke <jo...@gmail.com>.

ah, but (1) depends on OS/VM impl and (2) depends on subclass!
most LDMs will add still more data like id.  worth doing.


Johan Compagner wrote:
> 
> yes except for subclasses that also add references (and subclasses also
> cost
> 4 bytes if i remember correctly)
> 
> So lets do it. But don't expect that it will save something everytime,
> 
> johan
> 
> 
> On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>>
>> so that extra boolean was still inside the bucket allocated anyways?
>>
>> -igor
>>
>>
>> On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
>> >
>> > nope
>> > it will not do that
>> >
>> > by default new Object() takes 8 bytes
>> >
>> > new BooleanObject () (with 1 boolean reference)
>> >
>> > will take 16 bytes (so not 9 !!!)
>> >
>> > new BooleanAndObjectReferenceObject() (1 boolean and 1 object
>> reference)
>> >
>> > will take 16 bytes
>> >
>> > Object grow with 8 bytes at the time and if i remember correctly a
>> extends
>> > cost 4 bytes, martijn?)
>> >
>> > so EmptyObjectItselfButExtendBooleanObject will take 16 bytes
>> >
>> > but
>> >
>> > EmptyObjectItselfButExtendBooleanAndObjectReferenceObject will take 24
>> > bytes
>> >
>> > johan
>> >
>> >
>> > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>> > >
>> > > what do you mean it doesnt free memory? we removed the transient
>> boolean
>> > > field from model instance. it doesnt save anything when serializing,
>> but
>> > > it
>> > > reduces the footprint in ram.
>> > >
>> > > -igor
>> > >
>> > >
>> > > On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
>> > > >
>> > > > This is something martijn and i already discussed once for the
>> > > > loadabledetachable model i think
>> > > >
>> > > > For the simple one (one boolean and one reference object, so that
>> > class
>> > > > itself ) i doesn't directly free memory but it could be in some
>> cases
>> > > > when there is another reference is added that needs to be stored it
>> > > could
>> > > > help.
>> > > >
>> > > > But it should work fine.
>> > > >
>> > > > johan
>> > > >
>> > > >
>> > > > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>> > > > >
>> > > > > before johan has a chance to poke me, ldm.detach should read
>> > > > >
>> > > > > transientModelObject = IDetachable.DETACHED;
>> > > > >
>> > > > > not
>> > > > >
>> > > > > transientModelObject = null;
>> > > > >
>> > > > > -igor
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > >
>> > > > > On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
>> > > > > >
>> > > > > > jonathan and i have been brainstorming about removing private
>> > > > transient
>> > > > > > boolean attached=false from our detachable models, and after an
>> > hour
>> > > > > here is
>> > > > > > what we came up with (see attachment). i know we use some
>> custom
>> > > > > > serialization for models, etc so do you guys this is going to
>> > > > interfere
>> > > > > with
>> > > > > > that? it almost seems too simple so i am a bit suspicious. if
>> it
>> > > works
>> > > > > out
>> > > > > > it should save a fair bit of memory.
>> > > > > >
>> > > > > > one thing i know it will "break" is terracotta, it will need
>> extra
>> > > > > config
>> > > > > > to replicate what we do in readobject()
>> > > > > >
>> > > > > > -igor
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > >
>> > >
>> >
>> >
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/removing-that-pesky-transient-boolean-attached-from-detachable-models-tf3140623.html#a8709213
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: removing that pesky transient boolean attached from detachable models

Posted by Johan Compagner <jc...@gmail.com>.
yes except for subclasses that also add references (and subclasses also cost
4 bytes if i remember correctly)

So lets do it. But don't expect that it will save something everytime,

johan


On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> so that extra boolean was still inside the bucket allocated anyways?
>
> -igor
>
>
> On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
> >
> > nope
> > it will not do that
> >
> > by default new Object() takes 8 bytes
> >
> > new BooleanObject () (with 1 boolean reference)
> >
> > will take 16 bytes (so not 9 !!!)
> >
> > new BooleanAndObjectReferenceObject() (1 boolean and 1 object reference)
> >
> > will take 16 bytes
> >
> > Object grow with 8 bytes at the time and if i remember correctly a
> extends
> > cost 4 bytes, martijn?)
> >
> > so EmptyObjectItselfButExtendBooleanObject will take 16 bytes
> >
> > but
> >
> > EmptyObjectItselfButExtendBooleanAndObjectReferenceObject will take 24
> > bytes
> >
> > johan
> >
> >
> > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > >
> > > what do you mean it doesnt free memory? we removed the transient
> boolean
> > > field from model instance. it doesnt save anything when serializing,
> but
> > > it
> > > reduces the footprint in ram.
> > >
> > > -igor
> > >
> > >
> > > On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
> > > >
> > > > This is something martijn and i already discussed once for the
> > > > loadabledetachable model i think
> > > >
> > > > For the simple one (one boolean and one reference object, so that
> > class
> > > > itself ) i doesn't directly free memory but it could be in some
> cases
> > > > when there is another reference is added that needs to be stored it
> > > could
> > > > help.
> > > >
> > > > But it should work fine.
> > > >
> > > > johan
> > > >
> > > >
> > > > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > > >
> > > > > before johan has a chance to poke me, ldm.detach should read
> > > > >
> > > > > transientModelObject = IDetachable.DETACHED;
> > > > >
> > > > > not
> > > > >
> > > > > transientModelObject = null;
> > > > >
> > > > > -igor
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > > > >
> > > > > > jonathan and i have been brainstorming about removing private
> > > > transient
> > > > > > boolean attached=false from our detachable models, and after an
> > hour
> > > > > here is
> > > > > > what we came up with (see attachment). i know we use some custom
> > > > > > serialization for models, etc so do you guys this is going to
> > > > interfere
> > > > > with
> > > > > > that? it almost seems too simple so i am a bit suspicious. if it
> > > works
> > > > > out
> > > > > > it should save a fair bit of memory.
> > > > > >
> > > > > > one thing i know it will "break" is terracotta, it will need
> extra
> > > > > config
> > > > > > to replicate what we do in readobject()
> > > > > >
> > > > > > -igor
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Re: removing that pesky transient boolean attached from detachable models

Posted by Igor Vaynberg <ig...@gmail.com>.
so that extra boolean was still inside the bucket allocated anyways?

-igor


On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
>
> nope
> it will not do that
>
> by default new Object() takes 8 bytes
>
> new BooleanObject () (with 1 boolean reference)
>
> will take 16 bytes (so not 9 !!!)
>
> new BooleanAndObjectReferenceObject() (1 boolean and 1 object reference)
>
> will take 16 bytes
>
> Object grow with 8 bytes at the time and if i remember correctly a extends
> cost 4 bytes, martijn?)
>
> so EmptyObjectItselfButExtendBooleanObject will take 16 bytes
>
> but
>
> EmptyObjectItselfButExtendBooleanAndObjectReferenceObject will take 24
> bytes
>
> johan
>
>
> On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > what do you mean it doesnt free memory? we removed the transient boolean
> > field from model instance. it doesnt save anything when serializing, but
> > it
> > reduces the footprint in ram.
> >
> > -igor
> >
> >
> > On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
> > >
> > > This is something martijn and i already discussed once for the
> > > loadabledetachable model i think
> > >
> > > For the simple one (one boolean and one reference object, so that
> class
> > > itself ) i doesn't directly free memory but it could be in some cases
> > > when there is another reference is added that needs to be stored it
> > could
> > > help.
> > >
> > > But it should work fine.
> > >
> > > johan
> > >
> > >
> > > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > >
> > > > before johan has a chance to poke me, ldm.detach should read
> > > >
> > > > transientModelObject = IDetachable.DETACHED;
> > > >
> > > > not
> > > >
> > > > transientModelObject = null;
> > > >
> > > > -igor
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > > >
> > > > > jonathan and i have been brainstorming about removing private
> > > transient
> > > > > boolean attached=false from our detachable models, and after an
> hour
> > > > here is
> > > > > what we came up with (see attachment). i know we use some custom
> > > > > serialization for models, etc so do you guys this is going to
> > > interfere
> > > > with
> > > > > that? it almost seems too simple so i am a bit suspicious. if it
> > works
> > > > out
> > > > > it should save a fair bit of memory.
> > > > >
> > > > > one thing i know it will "break" is terracotta, it will need extra
> > > > config
> > > > > to replicate what we do in readobject()
> > > > >
> > > > > -igor
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Re: removing that pesky transient boolean attached from detachable models

Posted by Johan Compagner <jc...@gmail.com>.
nope
it will not do that

by default new Object() takes 8 bytes

new BooleanObject () (with 1 boolean reference)

will take 16 bytes (so not 9 !!!)

new BooleanAndObjectReferenceObject() (1 boolean and 1 object reference)

will take 16 bytes

Object grow with 8 bytes at the time and if i remember correctly a extends
cost 4 bytes, martijn?)

so EmptyObjectItselfButExtendBooleanObject will take 16 bytes

but

EmptyObjectItselfButExtendBooleanAndObjectReferenceObject will take 24 bytes

johan


On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> what do you mean it doesnt free memory? we removed the transient boolean
> field from model instance. it doesnt save anything when serializing, but
> it
> reduces the footprint in ram.
>
> -igor
>
>
> On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
> >
> > This is something martijn and i already discussed once for the
> > loadabledetachable model i think
> >
> > For the simple one (one boolean and one reference object, so that class
> > itself ) i doesn't directly free memory but it could be in some cases
> > when there is another reference is added that needs to be stored it
> could
> > help.
> >
> > But it should work fine.
> >
> > johan
> >
> >
> > On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > >
> > > before johan has a chance to poke me, ldm.detach should read
> > >
> > > transientModelObject = IDetachable.DETACHED;
> > >
> > > not
> > >
> > > transientModelObject = null;
> > >
> > > -igor
> > >
> > >
> > >
> > >
> > >
> > > On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > > >
> > > > jonathan and i have been brainstorming about removing private
> > transient
> > > > boolean attached=false from our detachable models, and after an hour
> > > here is
> > > > what we came up with (see attachment). i know we use some custom
> > > > serialization for models, etc so do you guys this is going to
> > interfere
> > > with
> > > > that? it almost seems too simple so i am a bit suspicious. if it
> works
> > > out
> > > > it should save a fair bit of memory.
> > > >
> > > > one thing i know it will "break" is terracotta, it will need extra
> > > config
> > > > to replicate what we do in readobject()
> > > >
> > > > -igor
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>

Re: removing that pesky transient boolean attached from detachable models

Posted by Igor Vaynberg <ig...@gmail.com>.
what do you mean it doesnt free memory? we removed the transient boolean
field from model instance. it doesnt save anything when serializing, but it
reduces the footprint in ram.

-igor


On 1/30/07, Johan Compagner <jc...@gmail.com> wrote:
>
> This is something martijn and i already discussed once for the
> loadabledetachable model i think
>
> For the simple one (one boolean and one reference object, so that class
> itself ) i doesn't directly free memory but it could be in some cases
> when there is another reference is added that needs to be stored it could
> help.
>
> But it should work fine.
>
> johan
>
>
> On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > before johan has a chance to poke me, ldm.detach should read
> >
> > transientModelObject = IDetachable.DETACHED;
> >
> > not
> >
> > transientModelObject = null;
> >
> > -igor
> >
> >
> >
> >
> >
> > On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
> > >
> > > jonathan and i have been brainstorming about removing private
> transient
> > > boolean attached=false from our detachable models, and after an hour
> > here is
> > > what we came up with (see attachment). i know we use some custom
> > > serialization for models, etc so do you guys this is going to
> interfere
> > with
> > > that? it almost seems too simple so i am a bit suspicious. if it works
> > out
> > > it should save a fair bit of memory.
> > >
> > > one thing i know it will "break" is terracotta, it will need extra
> > config
> > > to replicate what we do in readobject()
> > >
> > > -igor
> > >
> > >
> > >
> > >
> > >
> >
> >
>
>

Re: removing that pesky transient boolean attached from detachable models

Posted by Johan Compagner <jc...@gmail.com>.
This is something martijn and i already discussed once for the
loadabledetachable model i think

For the simple one (one boolean and one reference object, so that class
itself ) i doesn't directly free memory but it could be in some cases
when there is another reference is added that needs to be stored it could
help.

But it should work fine.

johan


On 1/30/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> before johan has a chance to poke me, ldm.detach should read
>
> transientModelObject = IDetachable.DETACHED;
>
> not
>
> transientModelObject = null;
>
> -igor
>
>
>
>
>
> On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
> >
> > jonathan and i have been brainstorming about removing private transient
> > boolean attached=false from our detachable models, and after an hour
> here is
> > what we came up with (see attachment). i know we use some custom
> > serialization for models, etc so do you guys this is going to interfere
> with
> > that? it almost seems too simple so i am a bit suspicious. if it works
> out
> > it should save a fair bit of memory.
> >
> > one thing i know it will "break" is terracotta, it will need extra
> config
> > to replicate what we do in readobject()
> >
> > -igor
> >
> >
> >
> >
> >
>
>

Re: removing that pesky transient boolean attached from detachable models

Posted by Igor Vaynberg <ig...@gmail.com>.
before johan has a chance to poke me, ldm.detach should read

transientModelObject = IDetachable.DETACHED;

not

transientModelObject = null;

-igor





On 1/29/07, Igor Vaynberg <ig...@gmail.com> wrote:
>
> jonathan and i have been brainstorming about removing private transient
> boolean attached=false from our detachable models, and after an hour here is
> what we came up with (see attachment). i know we use some custom
> serialization for models, etc so do you guys this is going to interfere with
> that? it almost seems too simple so i am a bit suspicious. if it works out
> it should save a fair bit of memory.
>
> one thing i know it will "break" is terracotta, it will need extra config
> to replicate what we do in readobject()
>
> -igor
>
>
>
>
>