FAQ
Hi!

I'm about to intermix a Perl web application with SWI-Prolog.
Currently Language::Prolog::Yaswi seems to be useful.

The prolog part ought to solve only one particular problem,
everything else is a mod_perl driven web app.

Now I'm not sure about its performance. I expect about 1 to 3 requests
per second at peak times and I don't know yet how long my prolog
programm will take.

Does Language::Prolog::Yaswi start a new "pl" process for every query?
The README talks about threads, so maybe it already does something
clever about this.

Or is there another recommended way to set up kind of an "swi prolog
application server" (a process that always runs and answers queries,
eg. via .*-RPC), that's accessible from Perl?


(Greeti+Tha)nX
Steffen
--
Steffen Schwigon <schwigon@webit.de>
Dresden Perl Mongers <http://dresden-pm.org/>

Search Discussions

  • BUDNEY, DANIEL L at Sep 29, 2005 at 2:08 pm
    If you are worried about the Language::Prolog::Yaswi module being a bottleneck, the proper action is to make up a group of test requests and write a script that calls the L:P:Y module repeatedly for these cases. You can then time the number of "typical" requests that can be handled each minute (and you can even compare the results of a "short" request vs. a "long" request). Run each case 100 or 1000 times in a loop.

    For the most meaningful results, you should run the tests on the actual server you are using for the website.

    -----Original Message-----
    From: Steffen Schwigon
    Sent: Thursday, September 29, 2005 4:02 AM
    To: perl-ai@perl.org
    Subject: Yaswi question

    Hi!

    I'm about to intermix a Perl web application with SWI-Prolog.
    Currently Language::Prolog::Yaswi seems to be useful.

    The prolog part ought to solve only one particular problem,
    everything else is a mod_perl driven web app.

    Now I'm not sure about its performance. I expect about 1 to 3 requests
    per second at peak times and I don't know yet how long my prolog
    programm will take.

    Does Language::Prolog::Yaswi start a new "pl" process for every query?
    The README talks about threads, so maybe it already does something
    clever about this.

    Or is there another recommended way to set up kind of an "swi prolog
    application server" (a process that always runs and answers queries,
    eg. via .*-RPC), that's accessible from Perl?


    (Greeti+Tha)nX
    Steffen
    --
    Steffen Schwigon <schwigon@webit.de>
    Dresden Perl Mongers <http://dresden-pm.org/>
  • Steffen Schwigon at Oct 4, 2005 at 3:41 pm
    Hi!

    Thanks for all your answers. And of course you are right, when you
    say that I just have to benchmark it.

    After struggling with some minor problems with Yaswi from mod_perl, I
    can now say that the performance impact is indeed quite small when
    using Language::Prolog::Yaswi.

    I compared
    - Language::Prolog::Yaswi from within a mod_perl application,
    - the same mod_perl framework without calls ti L::P::Yaswi,
    - the pure prolog httpd that is delivered with SWI Prolog.

    I used the threaded stress tester that comes with the swi prolog
    htttpd and measured time needed for 10000 requests from 8 threads).
    (Apache 1.3, mod_perl 1, Athlon 1800+)

    - mod_perl+Yaswi takes about 29sec.
    - plain mod_perl takes about 26sec.
    - httpd from swi takes about 20sec.

    As you can see, using Yaswi doesn't make my application much slower
    than it already is.

    GreetinX
    Steffen
    --
    Steffen Schwigon <schwigon@webit.de>
    Dresden Perl Mongers <http://dresden-pm.org/>
  • Ovid at Sep 29, 2005 at 3:15 pm

    --- Steffen Schwigon wrote:

    Now I'm not sure about its performance. I expect about 1 to 3
    requests
    per second at peak times and I don't know yet how long my prolog
    programm will take.

    Does Language::Prolog::Yaswi start a new "pl" process for every
    query?
    The README talks about threads, so maybe it already does something
    clever about this.
    The reason threads are mentioned is because Perl and SWI-Prolog must
    both have threads enabled or both NOT have threads enabled. Threads
    are not a requirement. I'm not aware that SWI-Prolog does start
    another process but I certainly wouldn't place a bet on that.

    I would strongly recommend Devel::Profiler or something similar on your
    code to find out where your true bottlenecks are. If you do find out
    your Prolog calls are slow, then you can spend the time tuning those
    queries (of course, if it's just too many Prolog queries in too short
    of a time, tuning might not help). On the other hand, if profiling
    can get you significant gains in the Perl portion, then you may get a
    win just by tuning Perl. If you can't speed up the Prolog, trying to
    replicate it's functionality in Perl may be difficult. Of course,
    there are tricks you can use to push much of the logic into a database
    and making multiple calls from Perl. That's probably slower but a good
    RDBMS has optimizations that Prolog often doesn't so it's worth
    exploring if you're stuck.

    If you really have problems with Prolog, I would suggest issuing a
    bunch of short Prolog queries and timing them and then issue some
    long-running queries. Time them both from Perl and directly in
    SWI-Prolog as if you were running it there. That can give you some
    idea as to the performance impact from Perl.

    Cheers,
    Ovid

    --
    If this message is a response to a question on a mailing list, please send
    follow up questions to the list.

    Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
  • Salvador "Fandiño" at Sep 29, 2005 at 3:26 pm

    --- Steffen Schwigon wrote:

    Hi!

    I'm about to intermix a Perl web application with SWI-Prolog.
    Currently Language::Prolog::Yaswi seems to be useful.

    The prolog part ought to solve only one particular problem,
    everything else is a mod_perl driven web app.

    Now I'm not sure about its performance. I expect about 1 to 3
    requests
    per second at peak times and I don't know yet how long my prolog
    programm will take.

    Does Language::Prolog::Yaswi start a new "pl" process for every
    query?
    No. It uses SWI-Prolog as a library, and the queries run inside the
    perl process. L::P::Y just converts data structures between perl and
    prolog. The overhead is relatively small, though it depends on how
    big the data structures passing through the interface are.

    Cheers,

    - Salvador



    __________________________________
    Yahoo! Mail - PC Magazine Editors' Choice 2005
    http://mail.yahoo.com

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupai @
categoriesperl
postedSep 29, '05 at 9:02a
activeOct 4, '05 at 3:41p
posts5
users4
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase