Hi Ernest, Yes, with your idea, the runtime of rule2 moved from 40 secs to about 900 millisec. Vielen Dank.
Now I will improve also rule3 as you said. Best regards, Cristian > -----Urspr|ngliche Nachricht----- > Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im > Auftrag von [EMAIL PROTECTED] > Gesendet: Mittwoch, 11. Mai 2005 19:53 > An: [email protected] > Betreff: Re: AW: JESS: Poor performance by loading large data > > eI think Negoita, Cristian wrote: > > > So, I see two improvements points: > > 1) Load the facts BEFORE the rules - this way the partial matches > times will be removed (loading without rules is indeed very fast) > > But then, of course, when you do load the rules, that will become > slow. You still have to do all the matching at some point! > > > > (defrule rule2 > > (declare (salience 10)) > > (Request > > (requestID ?req_requestid) > > ) > > (CustomerHit > > (requestID ?hit_requestid&:(= ?req_requestid > ?hit_requestid)) > > (hitID ?hit_hitid) > > (companyID ?hit_companyid) > > ) > > By calling the "=" function instead of doing direct matching, you're > doing two things: first, you're making the rule harder to read, and > second, you're stopping Jess from doing any useful indexing. Just > fixing this one thing may speed things up tremendously. Instead of > binding a slot and then testing the variable using "=", simply use the > previously existing variable to unify the two slots. So, for example, > > (Request > (requestID ?req_requestid) > ) > (CustomerHit > (requestID ?req_requestid) > (hitID ?hit_hitid) > (companyID ?hit_companyid) > ) > > Do that everywhere, and you'll see very significant improvements. > > > > (Lock > > (type ?lock_type&:(= ?companylock_type > ?lock_type)) > > (hitID ?lock_hitid&:(= ?lock_hitid ?hit_hitid)) > > (lockID ?lock_lockid) > > (creationDate ?lock_creationDate) > > ) > > (test (isStillValid ?lock_creationDate > ?companylock_validitydays)) > > Using the "test" CE tells Jess to form a partial match from the > previous pattern, and then further process it (or not) based on the > result of a test. Using "test" here, instead of doing your test > inline, is therefore forcing Jess to use vastly more memory than it > otherwise would. So instead of using "test", you could write > > (Lock > (type ?companylock_type) > (hitID ?hit_hitid) > (lockID ?lock_lockid) > (creationDate ?lock_creationDate&: > (isStillValid ?lock_creationDate > ?companylock_validitydays)) > ) > > Doing these two things should make a huge difference! > > > (defrule rule3 > > (declare (salience 5)) > > (Request > > (requestID ?req_requestid) > > ) > > (BadHit) > > (test (>= (count-query-results countNoOfBadLocksPerRequest > ?req_requestid) 2)) > > => (printout t "Bad RequestID found = " ?req_requestid crlf) > > ) > > Aiieeeee! Running a query on the LHS of a rule is an extremely > inefficient thing to do. Perhaps your rule that records bad hits could > include a count in the facts it asserts? That would also be an > enormous improvement. > > --------------------------------------------------------- > Ernest Friedman-Hill > Advanced Software Research 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] > -------------------------------------------------------------------- -------------------------------------------------------------------- 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] --------------------------------------------------------------------
