You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Eelco Hillenius <ee...@gmail.com> on 2008/05/04 03:27:56 UTC

Re: PropertyResolver redesign

>  The dataset I was sorting on was generated specifically to test the speed of
>  different comparators, and had a dataset of 100,000 elements, and I was
>  sorting using the standard sort method from the collections package,
>  accessed from Arrays.sort(). However, I now have data that times individual
>  calls of the Comparator's compare() method:

You would never load a data set of 100,000 elements (or even a 1,000
for that matter) in Wicket models, simply because you wouldn't display
that many components (your browser probably wouldn't be able to handle
that for instance). Furthermore, even if you would find the need to do
such sorting in-memory using Java, you would do that upfront, before
arriving at the user interface layer.

Eelco

Re: PropertyResolver redesign

Posted by James Carman <ja...@carmanconsulting.com>.
I have code that "records" a property invocation chain and bundles it
up into an object that can be "replayed" on a root object again (using
Commons Proxy's invocation recorder feature, not yet released).  It
has bindings for MVEL (which is the fastest currently), OGNL, Java
reflection, etc.  I don't think it's quite ready for "prime time" yet,
but you're more than welcome to it if you want it.

I would suggest you look into a simple MVEL-based implementation of
what you want.  MVEL is very fast and basically does what you're
looking for and it uses simple string expressions like Wicket does.

On Thu, May 8, 2008 at 11:10 PM, Miguel Munoz
<mm...@mainpointsystems.com> wrote:
>
>
> Eelco Hillenius wrote:
>>
>> One thing I'm wondering though is whether your more efficient version
>> still uses introspection? If that is the case, we would love to learn
>> what you did to make it run more efficiently. And - if you use
>> introspection - ... why use introspection when you need it to run very
>> efficiently (just write it out directly will run much faster).
>>
>> Eelco
>>
>>
>
> I am still using introspection because the current implementation uses
> property names specified in configuration files, although I may look into
> bypassing this. Here's how I suspect I get better efficiency: I instantiate
> distinct resolver objects for each property chain. When I instantiate one, I
> extract the getter's and setter's Method instances in the constructor. This
> means that when I set or retrieve the property, all I need to do is call
> Method.invoke(...). Since I'm sorting, I'm using the resolver for many
> different objects, so I don't have to retrieve the Method instance from the
> cache each time. (I suspect that's where I get most of the gains. HashMaps
> are generally pretty fast, but to improve sorting efficiency, I've found the
> best thing to do is speed up the individual comparisons.)
>
> (Also, since properties can be chained, I actually save an array of Getters.
> The longer the chain, the bigger the savings.)
>
> Earlier in this thread, Matej explained why this won't work for Wicket -- I
> guess your requirements are different from mine. I assume that a direct call
> to the property (e.g. item.getThing().getWidget().getVolume()) doesn't
> require anything to get cast to something else. I don't think my system
> would work if casting was needed, but I haven't tested that assumption.
>
> -----
> There are 10 kinds of people: Those who know binary and those who don't.
> --
> View this message in context: http://www.nabble.com/PropertyResolver-redesign-tp16495644p17140674.html
> Sent from the Wicket - Dev mailing list archive at Nabble.com.
>
>

Re: PropertyResolver redesign

Posted by Miguel Munoz <mm...@MainPointSystems.com>.

Eelco Hillenius wrote:
> 
> One thing I'm wondering though is whether your more efficient version
> still uses introspection? If that is the case, we would love to learn
> what you did to make it run more efficiently. And - if you use
> introspection - ... why use introspection when you need it to run very
> efficiently (just write it out directly will run much faster).
> 
> Eelco
> 
> 

I am still using introspection because the current implementation uses
property names specified in configuration files, although I may look into
bypassing this. Here's how I suspect I get better efficiency: I instantiate
distinct resolver objects for each property chain. When I instantiate one, I
extract the getter's and setter's Method instances in the constructor. This
means that when I set or retrieve the property, all I need to do is call
Method.invoke(...). Since I'm sorting, I'm using the resolver for many
different objects, so I don't have to retrieve the Method instance from the
cache each time. (I suspect that's where I get most of the gains. HashMaps
are generally pretty fast, but to improve sorting efficiency, I've found the
best thing to do is speed up the individual comparisons.)

(Also, since properties can be chained, I actually save an array of Getters.
The longer the chain, the bigger the savings.)

Earlier in this thread, Matej explained why this won't work for Wicket -- I
guess your requirements are different from mine. I assume that a direct call
to the property (e.g. item.getThing().getWidget().getVolume()) doesn't
require anything to get cast to something else. I don't think my system
would work if casting was needed, but I haven't tested that assumption.

-----
There are 10 kinds of people: Those who know binary and those who don't.
-- 
View this message in context: http://www.nabble.com/PropertyResolver-redesign-tp16495644p17140674.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.


Re: PropertyResolver redesign

Posted by Eelco Hillenius <ee...@gmail.com>.
>  Yes, I hoped I was making it clear that this wasn't a real-world test, it was
>  a stress test to exaggerate the inefficiencies. This makes them easier to
>  measure. Stress tests have their place.

Yeah, I got that idea :-) However,

> While my code clearly wouldn't ever
>  see a case like this, we would see something similar: When many users are on
>  line, many threads will be sorting many smaller datasets. In this case, I
>  still want the sort to run as efficiently as possible. This is why I was
>  measuring the efficiency of the PropertyResolver, and why I still feel
>  there's a faster way to do this.

Fair enough. It's certainly something to keep in mind with any
flexible/ introspection based thing you do that there might be a cost.
If your scale is large enough, it might be a problem. That said, I
(and as is clear from that thread, 'we') don't think the efficiency of
PropertyResolver is a problem, and we have in fact optimized it as
much as we can within what we feel are reasonable limits (so without
losing flexibility).

> That said, I have accepted the Wicket team's claim that we shouldn't use
> PropertyResolver in our own code. I have developed my own resolver, which,
> as I expected, runs much more efficiently. (We tried OGNL and MVEL, but
> neither was really suitable.)

Funny enough, we started out using OGNL in early Wicket versions, but
decided to create our own resolver so that we could optimize it for
just our cases. What you're doing is another optimization for your
situation. :-)

One thing I'm wondering though is whether your more efficient version
still uses introspection? If that is the case, we would love to learn
what you did to make it run more efficiently. And - if you use
introspection - ... why use introspection when you need it to run very
efficiently (just write it out directly will run much faster).

Eelco

Re: PropertyResolver redesign

Posted by Miguel Munoz <mm...@MainPointSystems.com>.
Yes, I hoped I was making it clear that this wasn't a real-world test, it was
a stress test to exaggerate the inefficiencies. This makes them easier to
measure. Stress tests have their place. While my code clearly wouldn't ever
see a case like this, we would see something similar: When many users are on
line, many threads will be sorting many smaller datasets. In this case, I
still want the sort to run as efficiently as possible. This is why I was
measuring the efficiency of the PropertyResolver, and why I still feel
there's a faster way to do this. 

That said, I have accepted the Wicket team's claim that we shouldn't use
PropertyResolver in our own code. I have developed my own resolver, which,
as I expected, runs much more efficiently. (We tried OGNL and MVEL, but
neither was really suitable.)


Eelco Hillenius wrote:
> 
>>  The dataset I was sorting on was generated specifically to test the
>> speed of
>>  different comparators, and had a dataset of 100,000 elements, and I was
>>  sorting using the standard sort method from the collections package,
>>  accessed from Arrays.sort(). However, I now have data that times
>> individual
>>  calls of the Comparator's compare() method:
> 
> You would never load a data set of 100,000 elements (or even a 1,000
> for that matter) in Wicket models, simply because you wouldn't display
> that many components (your browser probably wouldn't be able to handle
> that for instance). Furthermore, even if you would find the need to do
> such sorting in-memory using Java, you would do that upfront, before
> arriving at the user interface layer.
> 
> Eelco
> 
> 


-----
There are 10 kinds of people: Those who know binary and those who don't.
-- 
View this message in context: http://www.nabble.com/PropertyResolver-redesign-tp16495644p17067504.html
Sent from the Wicket - Dev mailing list archive at Nabble.com.