Title: RE: JESS: Optimization Question

Also, the following *might* be even faster - TBD:

(defrule prevent-logout
   (ActionForward (path ?url&:(neq (str-index "Logout.do" ?url) FALSE)))
=>
)

You can move the _expression_ in the (test) up into the pattern if your _expression_ doesn't depend on variables from another pattern bound lower in the pattern list.

Warning: In general, don't move the patterns around on the LHS to bind the variable earlier if doing so would greatly increase the number of partial matches. A careful analysis of your actual patterns and data will determine whether this can/should be done. The patterns with the fewest matches should be listed first on the LHS to reduce partial matches.

Good luck!

alan

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of John Aronson
Sent: Wednesday, July 07, 2004 4:04 PM
To: [EMAIL PROTECTED]
Subject: FW: JESS: Optimization Question


Thanks for the response. The class loading time wasn't a one time thing, it was a constant drag when I was running from 100 up to 10000 reps. 10,000 reps was taking over an hour so I didn't run that one a lot ;)

 
I did solve the problem though. I found that it was a lot faster to use Jess methods within the LHS part of my rules as opposed to making Java calls. For example, I was looking for a static string inside another string in the test clause of a rule.

 
;variable ?url is String variable defined by an earlier clause
 
;this is the slow version, using indexOf method in String class
(test (> (?url indexOf "Logout.do") -1))
 
;this is the fast version, using Jess method str-index
(test (neq (str-index "Logout.do" ?url) FALSE))
 
Changing to the fast version caused Jess to perform about 100 times faster and made it much less sensitive to the number of rules in the rule base.

 
I looked through your book and the online docs but I didn't see anything about this performance cost. I might have missed it.

 
John Aronson
Senior Software Engineer
Xaffire Inc.
(303) 642-4481 office
(720) 294-1235 fax
 
[EMAIL PROTECTED]
www.xaffire.com
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 07, 2004 4:47 PM
To: [EMAIL PROTECTED]
Subject: Re: JESS: Optimization Question
 
I think John Aronson wrote:
 
> The profiler reports that that almost all the execution time is spent
> loading classes. I'm hoping that fact means that there's something wrong
> with my code which I could fix to improve the performance.
 
It does look like a lot of time is being spent loading classes during
calls to "definstance" and something in ReflectFunctions; these are
clearly your application classes that Jess is, for some reason,
loading very slowly.
 
I suspect this is a "microbenchmark", and the problem may just be that
loading your classes is intrinsically slow -- for example, the first
Swing class loaded can often take a really long time because it can
drag in hundreds of other classes. In that case, I'd say you should
just run the thing 50,000 times instead of 1,000 times, and see if the
class loading time doesn't disappear down into the noise (because it
only happens once.) Based on your description, your benchmark likely
takes only a fraction of a second to run, discounting the JVM startup
time and any anomolous class loading behavior.
 
But in any case, Jess doesn't define its own class loader, or do
anything odd that would force the same class to be reloaded multiple
times.
 
 
---------------------------------------------------------
Ernest Friedman-Hill 
Science and Engineering PSEs        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov
 
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------
 

Reply via email to