From: T V Raman
Subject: How do I write this more efficiently?
Date: 
Message-ID: <1994Jan8.165807.26721@cs.cornell.edu>
Hi,

I have a large lisp-clos system implemented under Lucid 4.0.2.
(Incidentally, Lucid 4.1 GC's about 10 times more than 4.0.2 which is
why I have not switched)

Even under 4.0.2, my application spends a lot of time on the following
call to compute-applicable-methods:

( setf active-style  (find-if
                                  #'(lambda(style)
                                      (compute-applicable-methods
                                       #'reading-rule
                                       (list document
                                             style )))
                                  current-style ))

where style is a list of symbols, and document is a document object.

Generic function reading-rule takes two arguments, a document object
and a symbol.

The call to compute-applicable-methods is where the time is spent.


Is there a more efficient way to code the above?
Thanks,

--Raman
-- 
   T. V. Raman <·····@cs.cornell.edu>Tel: (607)255-9202  Fax:
255-4428
                       Office: 4116 Upson Hall,
Department of Computer Science, Cornell University Ithaca NY 14853-6201
From: Ken Anderson
Subject: Re: How do I write this more efficiently?
Date: 
Message-ID: <KANDERSO.94Jan13171524@wheaton.bbn.com>
In article <·····················@cs.cornell.edu> ·····@cs.cornell.edu (T V Raman) writes:

   Newsgroups: comp.lang.lisp,comp.lang.clos
   Path: news.bbn.com!usc!math.ohio-state.edu!cyber2.cyberstore.ca!nntp.cs.ubc.ca!uw-beaver!cornell!raman
   From: ·····@cs.cornell.edu (T V Raman)
   Keywords: Compute-applicable-methods efficient use
   Organization: Cornell Univ. CS Dept, Ithaca NY 14853
   Date: Sat, 8 Jan 1994 16:58:07 GMT
   Lines: 36
   Xref: news.bbn.com comp.lang.lisp:11677 comp.lang.clos:2264

   I have a large lisp-clos system implemented under Lucid 4.0.2.
   (Incidentally, Lucid 4.1 GC's about 10 times more than 4.0.2 which is
   why I have not switched)

Use some profiling or benchmarks to find what the difference is.  I've used
4.1 for quite some time and it is fine.

   Even under 4.0.2, my application spends a lot of time on the following
   call to compute-applicable-methods:

   ( setf active-style  (find-if
				     #'(lambda(style)
					 (compute-applicable-methods
					  #'reading-rule
					  (list document
						style )))
				     current-style ))

   where style is a list of symbols, and document is a document object.

   Generic function reading-rule takes two arguments, a document object
   and a symbol.

   The call to compute-applicable-methods is where the time is spent.


   Is there a more efficient way to code the above?
   Thanks,

Well, what do you do with the method bound to active-style anyway?
COMPUTE-APPLICABLE-METHODS is normally a "compile time" thing in the sense
that it's results are ususally cached.  These methods then get used as part
of generic function invocation as a list used by CALL-NEXT-METHOD.  If you
are going to execute active-style you could rewrite reading-rule to return
a function that does what you want.

However, i have found these things useful occasionally:

(defun effective-method-body (gf &rest args)
  "Shows the shape of the body of the effective method that is executed
when GF is applied to ARGS."
  (#+lucid clos::compute-effective-method-body
	   #-lucid clos::compute-effective-method-lambda ; AMOP
	   gf
	   (clos::compute-applicable-methods gf args)))

(defun lookup-effective-method (gf args)
  ;; Returns the actual function (effective method) that is run when
  ;; GF is applied to ARGS
  ;; You could use this to avoid dispatch overhead if you like.
  (CLOS::CHECKING/CACHING-DCODE-LOOKUP gf args))
--
Ken Anderson 
Internet: ·········@bbn.com
BBN STC              Work Phone: 617-873-3160
10 Moulton St.       Home Phone: 617-643-0157
Mail Stop 6/4c              FAX: 617-873-3776
Cambridge MA 02138
USA