Hi Ernest,

Thank you so much for your rapid reply. I have tried what you proposed and
it really significantly reduces the memory usage.

A problem is that we can't use suggestion 3 and 4 in our system because such
error:

     [java]   Message: Can't use funcalls in backchained patterns
MAIN::dynamic_triple.

Our system has to use backward-chained template here. Do you have any
suggestion on possible alternatives?

By the way, do you have any comprehensive document about the performance
issue? I have read the manual and Jess in action book, but both are talking
of this very briefly. I would also like to read your article about the OAV
triples.

Thank you so much.

Jinghai




On 10/26/07, Ernest Friedman-Hill <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> There are some very serious issues here that will effect both
> performance and memory usage. Fixing them should substantially reduce
> your memory footprint.
>
> First, I've have gone on record many times explaining why using
> generic OAV triples like this is a bad architectural choice. You're
> basically denying Jess some of its ability to downselect collections
> of working memory elements by hiding useful information. This forces
> larger indices to be built than would otherwise be needed, and that's
> one irreducible source of the large memory consumption here. I'll
> ignore this though, as changing it would presumably require you to
> rethink your whole project.
>
> Second, note that the "or" conditional element should only be use to
> express alternatives that actually differ in some way -- otherwise
> you're just building a more complex Rete network for no reason, which
> will, again, use more memory and run more slowly. The first "or"
> below could simply be written
>
> (need-authorized_triple
>       (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
>       (subject   ?owner)
>       (object    ?location)
>
> because ?owner and ?location will be bound to nil if the respective
> slots contain nil; the explicit nil matches accomplish nothing that
> the first pattern doesn't accomplish by itself, except expand the
> size of the Rete network and its memory consumption for this rule by
> a factor of four.
>
> Third, the "or" conditional element should not be used to express
> alternatives that differ only in the value of one slot in one pattern
> -- that's what the "or" connective is for. So, for example, the
> second "or" could be written more succinctly and more efficiently as
>
>   (and
>
>    (dynamic_triple
>     (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
>     (subject   " http://www-2.cs.cmu.edu/Group/rule1192814601";)
>     (object    " http://mycampus.cs.cmu.edu/ontology#Group";)
>    )
>
>     (dynamic_triple
>     (predicate "http://mycampus.cs.cmu.edu/ontology#include";)
>     (subject   "http://www-2.cs.cmu.edu/Group/rule1192814601 ")
>     (object    ?sender | "http://www-2.cs.cmu.edu/People/Anybody";)
>
>     )
>
>   )
>
> Fourth, you unify a bunch of facts on the "?day" variable, and then
> later downselect by restricting ?day to one of four values. This
> means you'll build a potentially huge set of partial matches, only to
> throw some large number of them away. The test to restrict the value
> of ?day should go at ?day's first use.
>
> Finally, regarding how that ?day test is done: doing something like
> this:
>
> (and
>
>    (dynamic_triple
>     (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
>     (subject   ?day)
>     (object    "http://mycampus.cs.cmu.edu/QOWL#Day";)
>    )
>
>     (test (member$ ?day (create$ " http://mycampus.cs.cmu.edu/
> day#Tuesday " "http://mycampus.cs.cmu.edu/day#Wednesday"; "http://
> mycampus.cs.cmu.edu/day#Thursday" " http://mycampus.cs.cmu.edu/
> day#Saturday" )))
>
>   )
>
> is going to create a new list of values to test each single fact
> that's considered here -- a waste of resources. Further, in Jess 7.0
> and earlier, it's going to waste memory building up unneeded partial
> matches. You could just write this:
>
> (and
>
>    (dynamic_triple
>     (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
>     (subject   ?day & :(or (eq ?day " http://mycampus.cs.cmu.edu/
> day#Tuesday ")
>                            (eq ?day "http://mycampus.cs.cmu.edu/
> day#Wednesday")
>                            (eq ?day " http://mycampus.cs.cmu.edu/
> day#Thursday")
>                            (eq ?day "http://mycampus.cs.cmu.edu/
> day#Saturday")))
>     (object    "http://mycampus.cs.cmu.edu/QOWL#Day";)
>    )
>
>
>
> On Oct 25, 2007, at 9:21 PM, Jinghai Rao wrote:
>
> > Hello everybody,
> >
> > We are using jess to develop an access control system. The access
> > control rule has been translated to a jess rule as shown below. We
> > notice that adding one of such rule consumes 500K - 1MB more
> > memory. I wonder if it is normal. Do you have any suggestion to
> > reduce the memory usage by either changing the rule format or
> > changing jess/java VM configuration?
> >
> > Here is an example of such rule. dynamic_triple and
> > authorized_triple use backward chaining.
> >
> > (defrule rule1192814601 (declare (salience 50))
> >
> >   (or
> >
> >     (need-authorized_triple
> >      (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
> >      (subject   ?owner)
> >      (object    ?location)
> >     )
> >     (need-authorized_triple
> >      (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
> >      (subject   nil)
> >      (object    ?location)
> >     )
> >     (need-authorized_triple
> >      (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
> >      (subject   ?owner)
> >      (object    nil)
> >     )
> >     (need-authorized_triple
> >      (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
> >      (subject   nil)
> >      (object    nil)
> >     )
> >
> >   )
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?owner)
> >    (object    "http://mycampus.cs.cmu.edu/ontology#Person ")
> >   )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/ontology#has_location";)
> >    (subject   ?owner)
> >    (object    ?location)
> >
> >    )
> >
> >   (dynamic_triple
> >    (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
> >    (subject   ?location)
> >    (object    "http://mycampus.cs.cmu.edu/ontology#Location";)
> >   )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?query)
> >    (object    " http://mycampus.cs.cmu.edu/QOWL#Query";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/QOWL#querytime";)
> >    (subject   ?query)
> >    (object    ?querytime)
> >
> >    )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/QOWL#gpstime";)
> >    (subject   ?query)
> >    (object    ?gpstime)
> >
> >    )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/QOWL#sender";)
> >    (subject   ?query)
> >    (object    ?sender)
> >
> >    )
> >
> >  )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?querytime)
> >    (object    " http://mycampus.cs.cmu.edu/QOWL#Datetime";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/QOWL#hasDay ")
> >    (subject   ?querytime)
> >    (object    ?day)
> >
> >    )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/QOWL#hasTime ")
> >    (subject   ?querytime)
> >    (object    ?time)
> >
> >    )
> >
> >  )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?gpstime)
> >    (object    "http://mycampus.cs.cmu.edu/QOWL#Datetime";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/QOWL#hasDay";)
> >    (subject   ?gpstime)
> >    (object    ?gpsday)
> >
> >    )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/QOWL#hasTime";)
> >    (subject   ?gpstime)
> >    (object    ?gpshourmin)
> >
> >    )
> >
> >  )
> >
> >  (or
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
> >    (subject   "http://www-2.cs.cmu.edu/Group/rule1192814601";)
> >    (object    " http://mycampus.cs.cmu.edu/ontology#Group";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/ontology#include";)
> >    (subject   "http://www-2.cs.cmu.edu/Group/rule1192814601";)
> >    (object    ?sender)
> >
> >    )
> >
> >  )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
> >    (subject   " http://www-2.cs.cmu.edu/Group/rule1192814601";)
> >    (object    " http://mycampus.cs.cmu.edu/ontology#Group";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate "http://mycampus.cs.cmu.edu/ontology#include ")
> >    (subject   "http://www-2.cs.cmu.edu/Group/rule1192814601 ")
> >    (object    " http://www-2.cs.cmu.edu/People/Anybody";)
> >
> >    )
> >
> >  )
> >
> >  )
> >
> >  (or
> >
> >  (and
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?day)
> >    (object    "http://mycampus.cs.cmu.edu/QOWL#Day ")
> >   )
> >
> >    (test (member$ ?day (create$ "http://mycampus.cs.cmu.edu/
> > day#Tuesday " " http://mycampus.cs.cmu.edu/day#Wednesday"; "http://
> > mycampus.cs.cmu.edu/day#Thursday" " http://mycampus.cs.cmu.edu/
> > day#Saturday" )))
> >
> >  )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
> >    (subject   ?time)
> >    (object    "http://mycampus.cs.cmu.edu/QOWL#Time";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/ROWL#any";)
> >    (subject   ?time)
> >    (object    "false")
> >
> >    )
> >
> >    (test (> ?time "0400"))
> >
> >    (test (< ?time "0700"))
> >
> >  )
> >
> >  )
> >
> >  )
> >
> >  (or
> >
> >  (and
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?gpsday)
> >    (object    " http://mycampus.cs.cmu.edu/QOWL#Day ")
> >   )
> >
> >    (test (member$ ?gpsday (create$ "http://mycampus.cs.cmu.edu/
> > day#Tuesday" " http://mycampus.cs.cmu.edu/day#Wednesday"; "http://
> > mycampus.cs.cmu.edu/day#Thursday" "http://mycampus.cs.cmu.edu/
> > day#Saturday " )))
> >
> >  )
> >
> >  (and
> >
> >   (dynamic_triple
> >    (predicate "http://www.w3.org/1999/02/22-rdf-syntax-ns#type ")
> >    (subject   ?gpshourmin)
> >    (object    "http://mycampus.cs.cmu.edu/QOWL#Time";)
> >   )
> >
> >    (dynamic_triple
> >    (predicate " http://mycampus.cs.cmu.edu/ROWL#any";)
> >    (subject   ?gpshourmin)
> >    (object    "false")
> >
> >    )
> >
> >    (test (> ?gpshourmin "0400"))
> >
> >    (test (< ?gpshourmin "0700"))
> >
> >  )
> >
> >  )
> >
> >  )
> >
> >
> >   =>
> >
> >  (assert
> >   (authorized_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?owner)
> >    (object    " http://mycampus.cs.cmu.edu/ontology#Person";)
> >   )
> >    )
> >  (assert
> >    (authorized_triple
> >    (predicate " http://mycampus.cs.cmu.edu/ontology#has_location";)
> >    (subject   ?owner)
> >    (object    ?location)
> >
> >    )
> >        )
> >  (assert
> >   (authorized_triple
> >    (predicate " http://www.w3.org/1999/02/22-rdf-syntax-ns#type";)
> >    (subject   ?location)
> >    (object    " http://mycampus.cs.cmu.edu/ontology#Location";)
> >   )
> >    )
> >     (add-to-log ruleID rule1192814601 conversationID ?query
> > location ?location)
> > )
> >
> >
> > Thank you very much.
> >
> > Jinghai
> >
> >
> >
> >
> >
> > --
> > ------------------------------------
> > Jinghai Rao
> > Project Scientist
> >
> > Institute for Software Research International
> > School of Computer Science
> > Carnegie Mellon University
> > 5000 Forbes Avenue, 234 Smith Hall,
> > Pittsburgh, PA 15213
> >
> > Telephone: +1 412 268 1357
> > Fax: +1 412 268 7287
> > Mobile: +1 412 580 9756
> > http://www.cs.cmu.edu/~jinghai <http://www.cs.cmu.edu/%7Ejinghai>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Informatics & Decision Sciences          Phone: (925) 294-2154
> Sandia National Labs                FAX:   (925) 294-2234
> PO Box 969, MS 9012                 [EMAIL PROTECTED]
> 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]
> .
> --------------------------------------------------------------------
>
>
>


-- 
------------------------------------
Jinghai Rao
Project Scientist

Institute for Software Research International
School of Computer Science
Carnegie Mellon University
5000 Forbes Avenue, 234 Smith Hall,
Pittsburgh, PA 15213

Telephone: +1 412 268 1357
Fax: +1 412 268 7287
Mobile: +1 412 580 9756
http://www.cs.cmu.edu/~jinghai <http://www.cs.cmu.edu/%7Ejinghai>

Reply via email to