Discussion:
Pooling, costs, etc.
h***@public.gmane.org
2003-01-02 15:37:02 UTC
Permalink
I am concerned about the complexity and expense of maintaining copies, however
there is an element of "correctness" in creating these copies; it ensures that
single-server and clustered behavior is the same ... just as a backup service
in a cluster receives only copies of persistent properties, so will a single-
server; it ensures that the copy is the same for both.

There's still room to cheat (especially by changing properties of objects
stored inside collections, when the collections are persistent properties), but
it stands out more, and the behavior and timing is easier to describe.

Given that the vast majority of persistant properties will be String, Date,
boolean, int, etc. (that is, easily identifyable immutables), the cost is
actually not so great.

The second-worst case in an object that is merely Serializable, since (deep)
copying via Serialization is pretty darn expensive.

The worst case is getting an exception because a particular object type can't
be copied.

I'll noodle on the idea of a "peer" that stores persistant state. I'm not
immediately seeing a way to do it that doesn't break most existing
applications, and I'm concerned that creating new pages will involve a page
spec, template and TWO classes (one for logic, one for data storage). Seems
less natural to me.

Again, on the applications I've worked on, persistent properties tend to be
pretty rare and, when present, are immutable objects. On the other hand, there
are lots of people out there with much more experience actually building
Tapestry applications than I do (perplexing, isn't it!).



--
hlship-***@public.gmane.org

http://tapestry.sf.net
hi,
The basic types, such as String, Number, Boolean work fine. It
differentiates between mutable and immutable objects. Immutable objects
are
String, Number, Boolean, java.util.Date (which is slightly fudging), Enum
and anything marked as IImmutable (a new marker interface for immutable
objects).
Mutable objects are tougher since the persistance wants to keep an
isolated
copy of properties. That is, fireObservedChange() results in a copy
being
made, and when a page is rolled back in a later request cycle, a copy (of
the copy) is made.
The problem is handling the copying of values. At best, its going to do
a
shallow copy. As a last resort, Serializable objects are serialized and
deserialzed (to make a deep copy).
I think exposing the pooling that has to happen inside tapestry to the
average component developer is a mistake. It just opens up a way of
shooting yourself in the foot, while giving very little advantage to app
developers in general. And it seems now in order to make the semantics
less confusing, you have to add more expensive and complicated behavior
(copying) to the framework... Now I do agree that the pooling of
expensive resources (templates, bindings, whatever else) is a goood
thing... however, i would separate it in two: make components non-pooled
and recreated all the time, and separate out the heavyweight portion into
another class that does need to know about pooling. The lightweight
component should delegate to the pooled instance when needed (Tapestry
should estabilish the association between it and the peer).
Component c = ... // new instance
ComponentPeer p = pool.getPeer(c);
c.setPeer( p );
// perform request...
p.detach()
c = null; // just forget about it...
pool.returnPeer(p);
I think this would make developers have to think about a lot less
"issues" that really have nothing to do with their application logic,
only how the framework is built. Writing components would become more
natural - you can use regular constructors and forget about detach and
it's sideffects.
i hope this doesnt sound much sillier or less efficient than an intricate
copying solution with special handling for immutables :)
best regards,
viktor
--
--
http://fastmail.fm - Email service worth paying for. Try it for free
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-contrib mailing list
https://lists.sourceforge.net/lists/listinfo/tapestry-contrib
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Viktor Szathmary
2003-01-02 16:45:23 UTC
Permalink
hi,
Post by h***@public.gmane.org
single-server and clustered behavior is the same ... just as a backup service
in a cluster receives only copies of persistent properties, so will a single-
server; it ensures that the copy is the same for both.
yeah, that's not a bad thing...
Post by h***@public.gmane.org
Given that the vast majority of persistant properties will be String, Date,
boolean, int, etc. (that is, easily identifyable immutables), the cost is
actually not so great.
but it's still inconvenient to clear stuff out in detach(), with
components it's even more so (implement interface, etc).
Post by h***@public.gmane.org
I'll noodle on the idea of a "peer" that stores persistant state. I'm not
immediately seeing a way to do it that doesn't break most existing
applications, and I'm concerned that creating new pages will involve a
page spec, template and TWO classes (one for logic, one for data storage).
Seems less natural to me.
the peer i was trying to describe is not for storing the persistent
properties, that could still be done with fireObservedChange().. it's for
the expensive stuff that made pooling neccessary to begin with - you
probably know better what these are, but i guess the component
specification, bindings, assets - which is usually not a whole lot
outside of the framework, so one would very rarely need to subclass the
Peer (like, never?).

as far as refactoring existing code goes, i think you should be able to
keep all but a few methods in the IComponent hierarchy, but make the
implementations delegate to the peer.. eg. getBinding(...) { return
peer.getBinding(...) } - this way existing client code doesnt have to be
changed much, other than removing the detach that's no longer needed...

best regards,
viktor
--
phraktle-***@public.gmane.org
--
http://fastmail.fm - Faster than the air-speed velocity of an
unladen european swallow


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
h***@public.gmane.org
2003-01-02 17:18:16 UTC
Permalink
Post by Viktor Szathmary
hi,
Post by h***@public.gmane.org
single-server and clustered behavior is the same ... just as a backup service
in a cluster receives only copies of persistent properties, so will a single-
server; it ensures that the copy is the same for both.
yeah, that's not a bad thing...
Post by h***@public.gmane.org
Given that the vast majority of persistant properties will be String, Date,
boolean, int, etc. (that is, easily identifyable immutables), the cost is
actually not so great.
but it's still inconvenient to clear stuff out in detach(), with
components it's even more so (implement interface, etc).
Mind Bridge is looking into taking care of that inconvienience by creating,
dynamically, a subclass that implements the necessary accessors, instance
variables, and other methods. Just like magic!

BTW ... I'm jealous, but also swamped. Letting someone else perform this
kind of major surgery on Tapestry is a real test of my dedication to a community
process ... (sniff) baby is growing up now (sniff).
Post by Viktor Szathmary
Post by h***@public.gmane.org
I'll noodle on the idea of a "peer" that stores persistant state. I'm not
immediately seeing a way to do it that doesn't break most existing
applications, and I'm concerned that creating new pages will involve a
page spec, template and TWO classes (one for logic, one for data storage).
Seems less natural to me.
the peer i was trying to describe is not for storing the persistent
properties, that could still be done with fireObservedChange().. it's for
the expensive stuff that made pooling neccessary to begin with - you
probably know better what these are, but i guess the component
specification, bindings, assets - which is usually not a whole lot
outside of the framework, so one would very rarely need to subclass the
Peer (like, never?).
as far as refactoring existing code goes, i think you should be able to
keep all but a few methods in the IComponent hierarchy, but make the
implementations delegate to the peer.. eg. getBinding(...) { return
peer.getBinding(...) } - this way existing client code doesnt have to be
changed much, other than removing the detach that's no longer needed...
best regards,
viktor
--
--
http://fastmail.fm - Faster than the air-speed velocity of an
unladen european swallow
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-contrib mailing list
https://lists.sourceforge.net/lists/listinfo/tapestry-contrib
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

Loading...