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: instruction-level tracing Date: Thu, 16 Sep 2010 13:14:14 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1284637168 11831 80.91.229.12 (16 Sep 2010 11:39:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 16 Sep 2010 11:39:28 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Sep 16 13:39:24 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OwCo9-0007ok-OE for guile-devel@m.gmane.org; Thu, 16 Sep 2010 13:39:18 +0200 Original-Received: from localhost ([127.0.0.1]:60056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwCjT-0000IE-JK for guile-devel@m.gmane.org; Thu, 16 Sep 2010 07:34:27 -0400 Original-Received: from [140.186.70.92] (port=47414 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OwCjL-0000I0-KO for guile-devel@gnu.org; Thu, 16 Sep 2010 07:34:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OwCjJ-0007ef-Ix for guile-devel@gnu.org; Thu, 16 Sep 2010 07:34:19 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:39779 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OwCjJ-0007eP-GO for guile-devel@gnu.org; Thu, 16 Sep 2010 07:34:17 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E0924D6F9C for ; Thu, 16 Sep 2010 07:34:16 -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=l sVrGfZORypBRcnanPT8qjOYK6I=; b=m5RASIqr7HfOPQMrb0bRByzXwDgIhsa8M tAzADhN18rBhmraLmNuIFsArSUu+qwzTv+Q6WJeZOnezFTfYc98qUzh1ti9rM8v0 3rIAnm2QvsgdYMENfNm56x54Oz2ruYTGl5bRKYXUhR/OLebz6hYZX8/+QyMxAo3r Ec+ZRTY1cc= 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=Oug CQnV6giF4tEpw9x0/9CTtpMSyGPO9na89cbuR442zdJS0dtnFZSiX6UwYAzRliwC PsjtcW/n4zbn46BeKOurIH5E7zI9/VE/JYjv6Pv9YIRtGl+o5vv4i1o0QdTzdU0w Rm/txtv70dJqG90b1RMKPZaPzl1Z1FODAvyw1lgQ= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id DDA34D6F9A for ; Thu, 16 Sep 2010 07:34:16 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [79.156.147.117]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id 18F05D6F99 for ; Thu, 16 Sep 2010 07:34:15 -0400 (EDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 56B3309C-C186-11DF-86F3-030CEE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10922 Archived-At: Hi, I de-bitrotted instruction-level tracing in the VM. Ideally it would display like ,disassemble does, but that would take some more work. Still, Guile's speed is mostly proportional to how many instructions are executed, besides amount of garbage consed, and this view can be interesting to people looking to squeeze more performance out of their code, or find ways that the compiler does things wrong. scheme@(guile-user)> (use-modules (srfi srfi-1)) scheme@(guile-user)> ,trace (fold cons '() '(a b c d)) #:instructions? #t 0: assert-nargs-ee/locals 2: load-symbol 10: link-now 11: variable-ref 12: load-symbol 20: link-now 21: variable-ref 22: make-eol 23: load-symbol 28: load-symbol 33: load-symbol 38: load-symbol 43: list 46: tail-call Tracing wraps a thunk around your form, so the first bit is the body of that thunk: (lambda () (fold cons '() '(a b c d)) Then it starts with the fold itself: (fold # () (a b c d)) 0: assert-nargs-ge 3: push-rest 6: reserve-locals 9: local-ref 11: br-if-not-null 15: br 49: local-ref 51: local-ref 53: local-set 55: local-set 57: br 19: local-ref 21: br-if-not-null 28: new-frame 29: local-ref 31: local-ref 33: car 34: local-ref 36: call |(cons a ()) 0: assert-nargs-ee 3: object-ref 5: subr-call Here we see that the cons is not inlined, as we are going through the subr-call trampoline instead of using the cons instruction directly. |(a) This is the result of calling cons... and so on. 38: local-ref 40: cdr 41: local-set 43: local-set 45: br 19: local-ref 21: br-if-not-null 28: new-frame 29: local-ref 31: local-ref 33: car 34: local-ref 36: call |(cons b (a)) 0: assert-nargs-ee 3: object-ref 5: subr-call |(b a) 38: local-ref 40: cdr 41: local-set 43: local-set 45: br This sequence, by the way, of local-set + br -- that is the rename + goto of a tail-call to a local function. Here we have renamed two variables -- the seed and the list. 19: local-ref 21: br-if-not-null 28: new-frame 29: local-ref 31: local-ref 33: car 34: local-ref 36: call |(cons c (b a)) 0: assert-nargs-ee 3: object-ref 5: subr-call |(c b a) 38: local-ref 40: cdr 41: local-set 43: local-set 45: br 19: local-ref 21: br-if-not-null 28: new-frame 29: local-ref 31: local-ref 33: car 34: local-ref 36: call |(cons d (c b a)) 0: assert-nargs-ee 3: object-ref 5: subr-call |(d c b a) 38: local-ref 40: cdr 41: local-set 43: local-set 45: br 19: local-ref 21: br-if-not-null 25: local-ref 27: return (d c b a) Have fun, Andy -- http://wingolog.org/