X-From-Line: sbcl-devel-admin@lists.sourceforge.net Thu Feb 03 12:25:28 2005
Return-path: <sbcl-devel-admin@lists.sourceforge.net>
Envelope-to: real-csr21@localhost
Delivery-date: Thu, 03 Feb 2005 12:25:28 +0000
Received: from localhost ([127.0.0.1]) by mu with esmtp (Exim 4.34)
	id 1Cwg35-0002FH-Rs
	for real-csr21@localhost; Thu, 03 Feb 2005 12:25:28 +0000
Received: from imap.hermes.cam.ac.uk [131.111.8.153]
	by localhost with IMAP (fetchmail-6.2.5)
	for real-csr21@localhost (single-drop); Thu, 03 Feb 2005 12:25:27 +0000
	(GMT)
Received: from ppsw-0-intramail.csi.cam.ac.uk ([192.168.128.130])
	by cyrus-5.csi.private.cam.ac.uk (Cyrus v2.1.16-HERMES)
	with LMTP; Thu, 03 Feb 2005 12:27:51 +0000
X-Sieve: CMU Sieve 2.2
Received: from lists-outbound.sourceforge.net ([66.35.250.225]:37501)
	by ppsw-0.csi.cam.ac.uk (mx.cam.ac.uk [131.111.8.140]:25)
	with esmtp id 1Cwg56-0002VW-1P (Exim 4.44) for csr21@cam.ac.uk
	(return-path <sbcl-devel-admin@lists.sourceforge.net>); Thu, 03 Feb 2005
	12:27:32 +0000
Received: from projects.sourceforge.net (sc8-sf-list1-b.sourceforge.net
	[10.3.1.7]) by sc8-sf-spam2.sourceforge.net (Postfix) with ESMTP
	id 23F8813E9A; Thu,  3 Feb 2005 04:27:30 -0800 (PST)
Received: from sc8-sf-mx1-b.sourceforge.net ([10.3.1.11]
	helo=sc8-sf-mx1.sourceforge.net)
	by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30)
	id 1Cwg1w-0005qx-Sr
	for sbcl-devel@lists.sourceforge.net; Thu, 03 Feb 2005 04:24:16 -0800
Received: from mail.metronet.co.uk ([213.162.97.75])
	by sc8-sf-mx1.sourceforge.net with esmtp (Exim 4.41)
	id 1Cwg1t-0005q2-Le
	for sbcl-devel@lists.sourceforge.net; Thu, 03 Feb 2005 04:24:16 -0800
Received: from mu (unknown [84.51.129.62])
	by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 5BA63415434
	for <sbcl-devel@lists.sourceforge.net>; Thu,  3 Feb 2005 12:23:33 +0000
	(GMT)
Received: from csr21 by mu with local (Exim 4.34) id 1Cwfxu-0002F9-I7
	for sbcl-devel@lists.sourceforge.net; Thu, 03 Feb 2005 12:20:06 +0000
To: SBCL <sbcl-devel@lists.sourceforge.net>
From: Christophe Rhodes <csr21@cam.ac.uk>
Message-ID: <sq6519kf7u.fsf@cam.ac.uk>
User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)
X-Spam-Score: 0.0 (/)
X-Spam-Report: Spam Filtering performed by sourceforge.net.
	See http://spamassassin.org/tag/ for more details.
	Report problems to
	http://sf.net/tracker/?func=add&group_id=1&atid=200001
	0.5 FROM_ENDS_IN_NUMS      From: ends in numbers
	0.0 SF_CHICKENPOX_PERIOD   BODY: Text interparsed with .
	0.0 SF_CHICKENPOX_COMMA    BODY: Text interparsed with ,
	0.0 SF_CHICKENPOX_SLASH    BODY: Text interparsed with /
	0.0 SF_CHICKENPOX_MINUS    BODY: Text interparsed with -
	0.0 SF_CHICKENPOX_APOSTROPHE BODY: Text interparsed with '
	-0.5 AWL AWL: From: address is in the auto white-list
Subject: [Sbcl-devel] PCL depessimization
Sender: sbcl-devel-admin@lists.sourceforge.net
Errors-To: sbcl-devel-admin@lists.sourceforge.net
X-BeenThere: sbcl-devel@lists.sourceforge.net
X-Mailman-Version: 2.0.9-sf.net
Precedence: bulk
List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/sbcl-devel>,
	<mailto:sbcl-devel-request@lists.sourceforge.net?subject=unsubscribe>
List-Id: <sbcl-devel.lists.sourceforge.net>
List-Post: <mailto:sbcl-devel@lists.sourceforge.net>
List-Help: <mailto:sbcl-devel-request@lists.sourceforge.net?subject=help>
List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/sbcl-devel>,
	<mailto:sbcl-devel-request@lists.sourceforge.net?subject=subscribe>
List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum=sbcl-devel>
X-Original-Date: Thu, 03 Feb 2005 12:20:05 +0000
Date: Thu, 03 Feb 2005 12:20:05 +0000
X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/
X-Cam-AntiVirus: No virus found
X-Cam-SpamDetails: scanned, SpamAssassin (score=0, FROM_CRSID -0.52,
	FROM_ENDS_IN_NUMS 0.52)
Lines: 120
Xref: mu list.sbcl-devel:7255
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===-=-="

--===-=-=

Hi,

At present, when SBCL sees a method such as
  (defmethod bar ((x foo)) (slot-value x 'x1))
it generates a method function which internally contains something like
  (let ((x (nth 2 args)))
    (declare (type foo x))
    ... (slot-value x 'x1))
where I am sweeping quite a lot of complexity under the rug.

The attached patch inserts the type declaration for x in this and
similar circumstances more selectively: it only does so when the
parameter specializer names a built-in-class or structure-class;
specifically, it no longer does so for clos classes, and it
_definitely_ doesn't do so any more for forthcoming-clos-classes --
classes which have been noted but not yet defined (usually defined
earlier in the same file).

Why not?  Well, a type check for a clos class is really quite
expensive -- involving classoid-typep and classoid-cell-typep.  A type
check for a clos class which hasn't even been defined yet is insanely
expensive -- involving a full call to %TYPEP and SPECIFIER-TYPE.  This
is especially so for applications which have their functionality built
up from many small methods -- each method function has its own type
check.  This is particularly annoying because for the 99.9999% of
times when standard method combination or one of the built-in method
combination types is used, the declaration is trivially true.

So I propose to remove these declarations as in the attached patch,
but just before I do, I wanted to check that no-one is relying on them
to detect bad user-defined method combinations or possibly bad calls
to call-next-method; however, the effect on a simple McCLIM
application is so noticeable, even on a very fast machine, that I
suspect that even if some kind of checking is required this is not the
mechanism to ensure it.  (I'd appreciate it if someone else felt like
trying their clim or other clos-based application with this patch,
just to reassure me that I'm not hallucinating the massive speedups).


--===-=-=
Content-Disposition: attachment; filename=pcl-declarations.diff
Content-Description: MORE SPEED (and not much LESS SAFETY)

? contrib/sb-simple-streams/test-data.tmp
Index: src/pcl/boot.lisp
===================================================================
RCS file: /cvsroot/sbcl/sbcl/src/pcl/boot.lisp,v
retrieving revision 1.89
diff -u -r1.89 boot.lisp
--- src/pcl/boot.lisp	13 Jan 2005 10:12:19 -0000	1.89
+++ src/pcl/boot.lisp	3 Feb 2005 12:11:47 -0000
@@ -614,23 +614,28 @@
 	 ;; Otherwise, we can usually make Python very happy.
 	 (let ((type (info :type :kind specializer)))
 	   (ecase type
-	     ((:primitive :defined :instance :forthcoming-defclass-type)
-	      `(type ,specializer ,parameter))
-	     ((nil)
+	     ((:primitive) `(type ,specializer ,parameter))
+	     ((:instance nil)
 	      (let ((class (find-class specializer nil)))
-		(if class
-		    `(type ,(class-name class) ,parameter)
-		    (progn
-		      ;; we can get here, and still not have a failure
-		      ;; case, by doing MOP programming like (PROGN
-		      ;; (ENSURE-CLASS 'FOO) (DEFMETHOD BAR ((X FOO))
-		      ;; ...)).  Best to let the user know we haven't
-		      ;; been able to extract enough information:
-		      (style-warn
-		       "~@<can't find type for presumed class ~S in ~S.~@:>"
-		       specializer
-		       'parameter-specializer-declaration-in-defmethod)
-		      '(ignorable))))))))))
+		(cond
+		  (class
+		   (if (typep class '(or built-in-class structure-class))
+		       `(type ,specializer ,parameter)
+		       ;; don't declare CLOS classes as parameters;
+		       ;; it's too expensive.
+		       '(ignorable)))
+		  (t
+		   ;; we can get here, and still not have a failure
+		   ;; case, by doing MOP programming like (PROGN
+		   ;; (ENSURE-CLASS 'FOO) (DEFMETHOD BAR ((X FOO))
+		   ;; ...)).  Best to let the user know we haven't
+		   ;; been able to extract enough information:
+		   (style-warn
+		    "~@<can't find type for presumed class ~S in ~S.~@:>"
+		    specializer
+		    'parameter-specializer-declaration-in-defmethod)
+		   '(ignorable)))))
+	     ((:forthcoming-defclass-type) '(ignorable)))))))
 
 (defun make-method-lambda-internal (method-lambda &optional env)
   (unless (and (consp method-lambda) (eq (car method-lambda) 'lambda))

--===-=-=


Cheers,

Christophe


--===-=-=--
