Re: JESS: Performance question
Greetings: I don't normally get all involved with this kind of thing but there is a practical example that shows how easily rule performance can go astray. This is taken directly from Girratano and Riley's book, Chapter 9.12, "The Importance of Pattern Order" (deffacts information (find-match a c e g) (item a) (item b) (item c) (item d) (item e) (item f) (item g) ) (defrule match-1 (find-match ?x ?y ?z ?w) (item ?x) (item ?y) (item ?z) (item ?w) => (assert (found-match ?x ?y ?z ?w) ) ) This should run quickly. But, change it slightly so that we replace match-1 with match-2 below (defrule match-1 (item ?x) (item ?y) (item ?z) (item ?w) (find-match ?x ?y ?z ?w) => (assert (found-match ?x ?y ?z ?w) ) ) If you watch-facts each time, you'll see the difference. HOW we write rules directly affects the performance of the rules. And since my "thing" is rulebase performance, I just couldn't resist. Have fun and enjoy the exploration. :-) SDG jco Senior Consultant / Architect KnowledgeBased Systems Corporation Co-founder and Director October Rules Fest -THE RuleBased Systems Conference Oct 22-24 Dallas, TX "This above all: to thine own self be true, And it must follow, as the night the day, Thou canst not then be false to any man." Hamlet, Act 1, Scene III http://www-tech.mit.edu/Shakespeare/hamlet/hamlet.1.3.html On Sep 3, 2008, at 12:26 PM, Ernest Friedman-Hill wrote: On Sep 3, 2008, at 12:54 PM, [EMAIL PROTECTED] wrote: Is the equality comparison using "==" or "equals"? It's jess.Value.equals(), which uses == for INTEGER, FLOAT, LONG, etc, but equals() for object types. -Russ -Original Message- From: [EMAIL PROTECTED] [mailto:owner-jess- [EMAIL PROTECTED] On Behalf Of Ernest Friedman-Hill Sent: Friday, August 29, 2008 2:26 PM To: jess-users Subject: Re: JESS: Performance question On Aug 29, 2008, at 12:58 PM, [EMAIL PROTECTED] wrote: The performance of the second version is much slower, especially as the number of facts increases. Is this just the overhead of my function call vs. "equals". Does anyone have suggestions about possible restructuring of the problem that might minimize the calls necessary?. For an equality comparison, Jess can use the hashcodes of the tested values to sort the facts into bins, and then actually do the comparison on only a comparatively small fraction of th facts. This is a big win. For a function, though, Jess has to do *all* the comparisons, since it doesn't know how to organize the data to eliminate any. As a side note, I'm noticing that the performance of Jess7.1p1 is slower than 70p2.I was expecting a performance increase because of the use of the "test" CE but that doesn't seem to be making a difference. Jess 7.1 has a lot of different optimizations, some for speed, some for space, and there's always a tradeoff between these two. Some programs do run faster (some *much* faster), while others might run a little slower. If you're seeing a nontrivial slowdown, though, I'd be interested in hearing the details. - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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] . - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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] .
Re: JESS: Performance question
On Sep 3, 2008, at 12:54 PM, [EMAIL PROTECTED] wrote: Is the equality comparison using "==" or "equals"? It's jess.Value.equals(), which uses == for INTEGER, FLOAT, LONG, etc, but equals() for object types. -Russ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ernest Friedman-Hill Sent: Friday, August 29, 2008 2:26 PM To: jess-users Subject: Re: JESS: Performance question On Aug 29, 2008, at 12:58 PM, [EMAIL PROTECTED] wrote: The performance of the second version is much slower, especially as the number of facts increases. Is this just the overhead of my function call vs. "equals". Does anyone have suggestions about possible restructuring of the problem that might minimize the calls necessary?. For an equality comparison, Jess can use the hashcodes of the tested values to sort the facts into bins, and then actually do the comparison on only a comparatively small fraction of th facts. This is a big win. For a function, though, Jess has to do *all* the comparisons, since it doesn't know how to organize the data to eliminate any. As a side note, I'm noticing that the performance of Jess7.1p1 is slower than 70p2.I was expecting a performance increase because of the use of the "test" CE but that doesn't seem to be making a difference. Jess 7.1 has a lot of different optimizations, some for speed, some for space, and there's always a tradeoff between these two. Some programs do run faster (some *much* faster), while others might run a little slower. If you're seeing a nontrivial slowdown, though, I'd be interested in hearing the details. - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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] . - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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]
RE: JESS: Performance question
Is the equality comparison using "==" or "equals"? -Russ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ernest Friedman-Hill Sent: Friday, August 29, 2008 2:26 PM To: jess-users Subject: Re: JESS: Performance question On Aug 29, 2008, at 12:58 PM, [EMAIL PROTECTED] wrote: > The performance of the second version is much slower, especially as > the number of facts increases. Is this just the overhead of my > function call vs. "equals". Does anyone have suggestions about > possible restructuring of the problem that might minimize the calls > necessary?. For an equality comparison, Jess can use the hashcodes of the tested values to sort the facts into bins, and then actually do the comparison on only a comparatively small fraction of th facts. This is a big win. For a function, though, Jess has to do *all* the comparisons, since it doesn't know how to organize the data to eliminate any. > > As a side note, I'm noticing that the performance of Jess7.1p1 is > slower than 70p2.I was expecting a performance increase because > of the use of the "test" CE but that doesn't seem to be making a > difference. Jess 7.1 has a lot of different optimizations, some for speed, some for space, and there's always a tradeoff between these two. Some programs do run faster (some *much* faster), while others might run a little slower. If you're seeing a nontrivial slowdown, though, I'd be interested in hearing the details. - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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]
Re: JESS: Performance question
On Aug 29, 2008, at 12:58 PM, [EMAIL PROTECTED] wrote: The performance of the second version is much slower, especially as the number of facts increases. Is this just the overhead of my function call vs. "equals". Does anyone have suggestions about possible restructuring of the problem that might minimize the calls necessary?. For an equality comparison, Jess can use the hashcodes of the tested values to sort the facts into bins, and then actually do the comparison on only a comparatively small fraction of th facts. This is a big win. For a function, though, Jess has to do *all* the comparisons, since it doesn't know how to organize the data to eliminate any. As a side note, I'm noticing that the performance of Jess7.1p1 is slower than 70p2.I was expecting a performance increase because of the use of the "test" CE but that doesn't seem to be making a difference. Jess 7.1 has a lot of different optimizations, some for speed, some for space, and there's always a tradeoff between these two. Some programs do run faster (some *much* faster), while others might run a little slower. If you're seeing a nontrivial slowdown, though, I'd be interested in hearing the details. - Ernest Friedman-Hill Informatics & Decision Sciences, Sandia National Laboratories PO Box 969, MS 9012, Livermore, CA 94550 http://www.jessrules.com 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]
RE: JESS: Performance question
The value of the testslot is a Java set, each element of the set is a name/value pair (Strings). Two are similar if for a given name, they have the same value (e.g. If the value of A_testslot is "Foo=1;Bar=2" and B_testslot = "Foo=1", they are similar but obviously not equal. However, "Foo=1;Bar=2" is not similar to "Foo=1;Bar=3"). I'm using the semi-colon to distinguish the members of the set. -Russ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wolfgang Laun Sent: Friday, August 29, 2008 1:36 PM To: jess-users@sandia.gov Subject: Re: JESS: Performance question On 8/29/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > (MetricValue (name "foo") > (group "A") > (testslot ?A_testslot) > ) > (MetricValue (name "foo") > (group "B") > (testslot ?B_testslot&:(similar ?B_testslot > ?A_testslot) > ) > ) > (test (> ?A_val ?B_Val)) > > The performance of the second version is much slower, especially as > the number of facts increases. Is this just the overhead of my function call vs. > "equals". Does anyone have suggestions about possible restructuring > of the problem that might minimize the calls necessary?. What does (similar) do? How is it implemented? Wolfgang 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]
Re: JESS: Performance question
On 8/29/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > (MetricValue (name "foo") > (group "A") > (testslot ?A_testslot) > ) > (MetricValue (name "foo") > (group "B") > (testslot ?B_testslot&:(similar ?B_testslot ?A_testslot) > ) > ) > (test (> ?A_val ?B_Val)) > > The performance of the second version is much slower, especially as the > number of facts increases. Is this just the overhead of my function call vs. > "equals". Does anyone have suggestions about possible restructuring of the > problem that might minimize the calls necessary?. What does (similar) do? How is it implemented? Wolfgang 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]