From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthew Mundell Newsgroups: gmane.emacs.devel Subject: Re: Compilation to native Date: 12 Apr 2004 21:20:21 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87k70lhrsq.fsf@sno.mundell.ukfsn.org> References: <87eks0654s.fsf@sno.mundell.ukfsn.org> <87n06bp4ng.fsf@sno.mundell.ukfsn.org> <877jxccutf.fsf@sno.mundell.ukfsn.org> <87k712gesk.fsf@sno.mundell.ukfsn.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1081801344 22695 80.91.224.253 (12 Apr 2004 20:22:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 12 Apr 2004 20:22:24 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Apr 12 22:22:14 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BD7wb-00054K-00 for ; Mon, 12 Apr 2004 22:22:13 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BD7wb-0004nl-00 for ; Mon, 12 Apr 2004 22:22:13 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BD6zL-0001xm-0r for emacs-devel@quimby.gnus.org; Mon, 12 Apr 2004 15:20:59 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BD6yj-0001wr-OM for emacs-devel@gnu.org; Mon, 12 Apr 2004 15:20:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BD6yh-0001wM-R9 for emacs-devel@gnu.org; Mon, 12 Apr 2004 15:20:20 -0400 Original-Received: from [217.158.120.143] (helo=mail.ukfsn.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BD6yh-0001w8-9V; Mon, 12 Apr 2004 15:20:19 -0400 Original-Received: from localhost (lucy.ukfsn.org [127.0.0.1]) by mail.ukfsn.org (Postfix) with ESMTP id 6FF8DE6DCB; Mon, 12 Apr 2004 21:17:53 +0100 (BST) Original-Received: from mail.ukfsn.org ([127.0.0.1]) by localhost (lucy.ukfsn.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32672-13; Mon, 12 Apr 2004 21:17:53 +0100 (BST) Original-Received: from sno.mundell.ukfsn.org (dsl213-218-238-16.as15444.net [213.218.238.16]) by mail.ukfsn.org (Postfix) with ESMTP id 1A75FE6DB9; Mon, 12 Apr 2004 21:17:53 +0100 (BST) Original-Received: from sno.mundell.ukfsn.org ([10.0.0.3]) by sno.mundell.ukfsn.org with esmtp (Exim 3.36 #1 (Debian)) id 1BD7uo-0001N0-00; Mon, 12 Apr 2004 21:20:22 +0100 Original-To: rms@gnu.org Original-Lines: 71 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21533 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21533 Matthew Mundell writes: > Richard Stallman writes: > > [...] > > Anyway, such a small speedup is not worth the trouble. > > Compilation of CCL may be worth while. Or optimization > > of the CCL interpreter may be possible. > > This is for the record, at least. The speedup is a little better with > Fgtr inlined into the native, a few excess memory instructions saved, > and, where possible, objects passed between byte operations using > registers instead of the stack. > > Byte compiled: > ("Tue Mar 30 21:54:05 2004" "Tue Mar 30 21:54:21 2004") 16 s > ("Tue Mar 30 21:54:26 2004" "Tue Mar 30 21:54:42 2004") 16 s > ("Tue Mar 30 21:54:45 2004" "Tue Mar 30 21:55:01 2004") 16 s > > Compiled from byte code to native: > ("Tue Mar 30 21:55:43 2004" "Tue Mar 30 21:55:49 2004") 6 s > ("Tue Mar 30 21:55:51 2004" "Tue Mar 30 21:55:58 2004") 7 s > ("Tue Mar 30 21:56:01 2004" "Tue Mar 30 21:56:07 2004") 6 s > > There is the possibility of further improvement, especially for this > example, by moving Lisp object referencing and setting out of loops. > This will surely be tricky, though, if only because the functions > called by the byte code operations could change these objects. This optimisation more than doubles the speed of the generated function. The optimisation adds two new byte operations. As a start the new operations always take parameters that are four bytes wide. I think the loading of these four bytes is the cause of the slower byte interpretation. Byte compiled: ("Mon Apr 12 18:03:01 2004" "Mon Apr 12 18:03:20 2004") 19 s ("Mon Apr 12 18:03:50 2004" "Mon Apr 12 18:04:09 2004") 19 s Compiled from byte code to native: ("Mon Apr 12 18:05:24 2004" "Mon Apr 12 18:05:26 2004") 2 s ("Mon Apr 12 18:05:45 2004" "Mon Apr 12 18:05:48 2004") 3 s An equivalent primitive runs in under a second. I think the speed difference between the primitive and the generated native is largely due to type checking and type extraction done in the loop of the generated native. Perhaps this could be also be optimised out of the loop. I think that may be fairly difficult. > [...] > The original figures: > > > (silly-loop 100000000) > > => ("Sat Feb 28 10:04:39 2004" "Sat Feb 28 10:05:30 2004") ; 51 secs > > > > (byte-compile 'silly-loop) > > (silly-loop 100000000) > > => ("Sat Feb 28 10:06:37 2004" "Sat Feb 28 10:06:53 2004") ; 16 secs > > > > (native-compile 'silly-loop) > > (silly-loop 100000000) > > => ("Sat Feb 28 10:17:13 2004" "Sat Feb 28 10:17:22 2004") ; 9 secs The test function (aka silly-loop) is below. (defun test-simple (n) "Return time before and after N iterations of a loop." (let ((t1 (current-time-string))) (while (> (setq n (1- n)) 0)) (list t1 (current-time-string))))