From: Vagif Verdi
Subject: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143264839.180162.52040@j33g2000cwa.googlegroups.com>
Hi,
Is KnowledgeWorks usable in multi-process environment ?
We are going to use it on the server, accessible via web server
(protable aserve)
But it looks like there's no way to create separate engine and facts
base for each request.
Engine is shared.
I know for example that in LISA there's special macro
with-inference-engine that is designed for exactly this purpose - using
it in multi-process environment.
Is there anything like that in KnowledgeWorks ?

From: Arthur Lemmens
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <op.s6y9eyttwpmq96@news.xs4all.nl>
Vagif Verdi <···········@gmail.com> wrote:

> But it looks like there's no way to create separate engine and facts
> base for each request.
> Engine is shared.
> I know for example that in LISA there's special macro
> with-inference-engine that is designed for exactly this purpose - using
> it in multi-process environment.
> Is there anything like that in KnowledgeWorks ?

I recently had a similar problem and asked Lispworks.  They suggested
that it might be possible to use KnowledgeWorks' rule contexts to deal
with this.

Arthur Lemmens
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143306633.890107.311000@i39g2000cwa.googlegroups.com>
Did it solve your problem ?
I'm confused. Contexts deal with rules not with facts.
Facts are still shared.
So if one request clears facts base, loads facts and starts inference
engine, and during this process second requests clears facts base,
loads it's own facts, what is gonna happen to process of first request
?

I hope they have mechanizm of separate inference engines. Otherwise i'm
screwed big time :(
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143313526.824193.156640@i39g2000cwa.googlegroups.com>
KnowledgeWorks is *not* reentrant, as far as I know. We've been using
it for several years now and I know of no obvious way to instantiate
multiple inference-engine instances within a single Lisp image. We're
getting around this by using multiple Lisp OS processes.

I'm not sure how one would emulate this behavior with contexts.

Lisa (http://lisa.sf.net) supports multiple inference engines, if that
is an alternative for you.

Peace, david
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143313889.042061.38080@v46g2000cwv.googlegroups.com>
Maybe you're not necessarily screwed. If you made your call to INFER a
critical section, protecting it with a mutex, would that mess up your
app's throughput too much? If each connection required its own
factbase, perhaps you could annotate each connection's facts with a
unique tag to keep them separated...

Just thinking "out loud" here. KW is very good; don't give up on it too
quickly...

- david
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143314654.860670.296610@g10g2000cwb.googlegroups.com>
OMG! That's awful news for me. :(
Yes, i can make technical workarounds, like marking each object with
sessionid.
But it will convolute code. I will have to add sessionid constraint
into EACH rule.
I will have to manually empty object base fact by fact, based on
sessionid after each request (bye bye (reset) )

I do not want even think about when different requests will need to
fire different set of rules.

I sent email to Lispworks folks, so I'll wait their response.
But if you are right, then the only option for me would be switch to
LISA.

You said something about  multiple Lisp OS processes.
Can you rovide more details on how do you do it ? How expensive it is
(memory, cpu)
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143331200.264624.103920@i40g2000cwc.googlegroups.com>
We have multiple instances of our app running, each with a unique port
id for incoming connections. For a web service like yours, though, that
needs many simultaneous connections to the Lisp backend (I'm guessing
here), that solution probably won't scale for you.

The "session id" thingy needn't overly convolute the rulebase, but
you're right -- it will add a bit of cruft to your code. Also, the LW
4.4 version of KW supports truth maintenance, so even if you can't use
RESET you *can* possibly use ERASE to remove an anchor fact and have
all dependent facts removed transparently. However, this isn't a
general solution and it might make your app overly complicated (and
eventually unmaintainable if it grows large).

Check out the section on multi-processing for information about
mutexes. As for KW, wait and see what LW says; those folks are great
and coming up with custom-made solutions. I'd be interested to know if
LW has a "secret" way to accomplish what you want. Please let us know.

-- david
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143342796.946558.46620@i39g2000cwa.googlegroups.com>
Yes, LW support is really fast and helpfull.
For instance KnowledgeWorks did not have a way to access rules
docstring.
I sent them email about it. They sent me patch next day.
Unfortunately this is different case. I'll wait for LW answer, but I'm
almost certain they will not be able to fix it with a mere path. Making
KnowledgeWorks fit to multi-process environment would require major
overhaul.

For now I'll investigate LISA. It provides all I currently use in
Knowledgeworks. (I do not use backward chaining)

Do you know any other lisp rete implementation besides KnowledgeWorks
and LISA ?
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143394336.261196.215730@i40g2000cwc.googlegroups.com>
Lisa is the only Lisp Rete implementation I know of that offers
re-entrancy. There's a project called JLisa (Lisa in Java) --
http://jlisa.sf.net -- that uses Armed Bear Common Lisp (ABCL). ABCL is
a remarkable effort that offers a Common Lisp implementation written in
Java, and it is able to run Lisa apps. Maybe you should give this a
serious look; it's possible this project has added features to JLisa
that my version doesn't offer.

-- david
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143409673.277672.279840@j33g2000cwa.googlegroups.com>
I saw JLisa
This is from Armed Bear site:

ABCL is a very young implementation. You are certain to encounter bugs.

ABCL 0.0.9 fails 54 out of 21344 tests in the GCL ANSI test suite.

ABCL's CLOS is intolerably slow and does not handle on-the-fly
redefinition of classes correctly. There is no support for the long
form of DEFINE-METHOD-COMBINATION, and certain other required CLOS
features are also missing. There's no MOP worth mentioning.
-----------------------

Besides if I would decide to go java way, drools.org is the best free
rete engine on java.
And it is specificly designed to be operated in server environment.
It is very good. But mind-boggling mixture of xml and java is too scary.
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143409978.493281.113710@i39g2000cwa.googlegroups.com>
The slow clos implementation would be a show-stopper for us to be sure.
Ah well...

david
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143591614.562441.128400@i39g2000cwa.googlegroups.com>
Follow up from LW
Renetrant KW is scheduled for LW 5 due June 2006

I'm going to use LISA until they have new version of KW.
Rules are quite easy to migrate.
From: David E. Young
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143732353.267977.242310@u72g2000cwu.googlegroups.com>
Hey, that's awesome! I've heard some very cool things about 5.0. Thanks
for the update.

dey
From: Vagif Verdi
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <1143315024.355878.266130@i39g2000cwa.googlegroups.com>
>If you made your call to INFER a
critical section, protecting it with a mutex, would that mess up your
app's throughput too much?

How do I "protect it with mutex" ? I would appreciate smaple code, or
manual reference about working with mutexes in lispworks
From: Paolo Amoroso
Subject: Re: KnowledgeWorks in multi-process environment
Date: 
Message-ID: <877j6h6qk8.fsf@plato.moon.paoloamoroso.it>
"Vagif Verdi" <···········@gmail.com> writes:

> How do I "protect it with mutex" ? I would appreciate smaple code, or
> manual reference about working with mutexes in lispworks

See:

  The Common Lisp Cookbook - Threads
  http://cl-cookbook.sourceforge.net/process.html

particularly section "Locks":

  http://cl-cookbook.sourceforge.net/process.html#locks


Paolo
-- 
Why Lisp? http://wiki.alu.org/RtL%20Highlight%20Film
The Common Lisp Directory: http://www.cl-user.net