From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: ballpark rtl speeds Date: Thu, 07 Jun 2012 10:47:44 +0200 Message-ID: <87ipf3jyof.fsf@pobox.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1339067693 21595 80.91.229.3 (7 Jun 2012 11:14:53 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Jun 2012 11:14:53 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jun 07 13:14:52 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Scafy-0005XF-LG for guile-devel@m.gmane.org; Thu, 07 Jun 2012 13:14:51 +0200 Original-Received: from localhost ([::1]:49676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scafy-0005uP-9b for guile-devel@m.gmane.org; Thu, 07 Jun 2012 07:14:50 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scafp-0005sR-1d for guile-devel@gnu.org; Thu, 07 Jun 2012 07:14:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Scafn-0000xm-1Y for guile-devel@gnu.org; Thu, 07 Jun 2012 07:14:40 -0400 Original-Received: from a-pb-sasl-sd.pobox.com ([74.115.168.62]:39036 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Scafm-0000wl-Mt for guile-devel@gnu.org; Thu, 07 Jun 2012 07:14:38 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 891216597 for ; Thu, 7 Jun 2012 07:14:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:date:message-id:mime-version:content-type; s=sasl; bh=q kR91R1B7p0gdnMCOe4rSbIyH4o=; b=lMWTmstMpYpigx19cTlIkaxZdy5X1XKjt xyiJ+xTyzQRKDNixdX/DcpMicHfSoRmfv30D7UJEtHm31KF4cyvxTdlCunIQmtx/ 6GaMT1JWBQwCNC+KN6nv/nf/J9DAPp0JhXVVyhnSTXY6EdHe3iMfcNka6kINkoQl q+C9M1R3Xw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :date:message-id:mime-version:content-type; q=dns; s=sasl; b=q0j Of0EEbInFM9G6svF+0LE6uJDAPiOjuaNjWFjsfp5SHE8htlgO/Vbl9XkwiI56ufO rySK2yv9+sOf3gaUNGcTtqUOziJgg6k8sj1fBrLMS+P6WxL4XPx923soxqq7TX9d EC8kr2dmqaVAlCk+rYbxKWWGFGz62wOUXmFcDbT0= Original-Received: from a-pb-sasl-sd.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTP id 8317A6596 for ; Thu, 7 Jun 2012 07:14:35 -0400 (EDT) Original-Received: from badger (unknown [90.164.198.39]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-sd.pobox.com (Postfix) with ESMTPSA id A586A6595 for ; Thu, 7 Jun 2012 07:14:34 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) X-Pobox-Relay-ID: F662D2B8-B091-11E1-A32A-E981AF15ED39-02397024!a-pb-sasl-sd.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 74.115.168.62 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:14562 Archived-At: Hi, Some ballpark measurements of the overhead of the old VM, the new VM, and C (compiled with gcc -g -O0). Old interpreter: $ guile --no-debug > (define (countdown* n) (let lp ((n n)) (if (zero? n) #t (lp (1- n))))) > ,time (countdown* 1000000000) ;; 14.054572s real time, 14.033213s run time. 0.000000s spent in GC. New interpreter: > (use-modules (system vm rtl)) > (define countdown (assemble-program '((begin-program countdown 1) (assert-nargs-ee/locals 1 2) (br fix-body) (label loop-head) (load-constant 2 0) (br-if-= 1 2 out) (sub1 1 1) (br loop-head) (label fix-body) (mov 1 0) (br loop-head) (label out) (load-constant 0 #t) (return 0)))) > ,time (countdown 1000000000) ;; 6.023658s real time, 6.014166s run time. 0.000000s spent in GC. Note that this is not the ideal bytecode -- there are two branches per loop iteration when there could just be one. But it's what the existing tree-il compiler would produce. C, with gcc -O0, disassembled: #include int main (int argc, char *argv[]) { 400514: 55 push %rbp 400515: 48 89 e5 mov %rsp,%rbp 400518: 48 83 ec 20 sub $0x20,%rsp 40051c: 89 7d ec mov %edi,-0x14(%rbp) 40051f: 48 89 75 e0 mov %rsi,-0x20(%rbp) if (argc != 2) 400523: 83 7d ec 02 cmpl $0x2,-0x14(%rbp) 400527: 74 07 je 400530 return 1; 400529: b8 01 00 00 00 mov $0x1,%eax 40052e: eb 2e jmp 40055e long l = atol (argv[1]); 400530: 48 8b 45 e0 mov -0x20(%rbp),%rax 400534: 48 83 c0 08 add $0x8,%rax 400538: 48 8b 00 mov (%rax),%rax 40053b: 48 89 c7 mov %rax,%rdi 40053e: e8 dd fe ff ff callq 400420 400543: 48 89 45 f8 mov %rax,-0x8(%rbp) while (l--); 400547: 90 nop 400548: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp) 40054d: 0f 95 c0 setne %al 400550: 48 83 6d f8 01 subq $0x1,-0x8(%rbp) 400555: 84 c0 test %al,%al 400557: 75 ef jne 400548 return 0; 400559: b8 00 00 00 00 mov $0x0,%eax } 40055e: c9 leaveq 40055f: c3 retq $ time ./a.out 1000000000 real 0m2.061s user 0m2.056s sys 0m0.000s Of course with -O2 the loop goes away entirely ;) But it's an interesting exercise. Andy -- http://wingolog.org/