unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: SRFI-9 on top of raw structs
Date: Mon, 07 Dec 2009 18:25:36 +0100	[thread overview]
Message-ID: <87skbmzofj.fsf@gnu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

Hello,

In the ‘wip-vlist’ branch (which is about implementing Bagwell’s vlists)
SRFI-9 is reimplemented in terms of raw structs, instead of records.

The advantage is that it makes it easy to write a macro-generating macro
akin to Dybvig’s ‘define-integrable’ [0] and use it to define record
accessors such that direct calls to accessors are effectively inlined.

On the attached use case, inlining reduces execution time by ~15%.  It
also has a noticeable impact on the vlist implementation itself.

If there are no objections I’ll commit it to ‘master’.

Thanks,
Ludo’.

[0] http://www.scheme.com/tspl3/syntax.html#./syntax:s57
    Thanks to Andy for pointing it out!


[-- Attachment #2: The \"bench\" --]
[-- Type: text/plain, Size: 467 bytes --]

(use-modules (srfi srfi-9)
             (ice-9 time))

(define-record-type <foo>
  (make-foo x)
  foo?
  (x get-x))

(define s (make-foo 1))

(define n 7000000)

(time (let loop ((i n))
        (and (> i 0)
             (begin
               (get-x s)
               (loop (1- i))))))

(time (let ((get-x get-x)) ;; prevent inlining
        (let loop ((i n))
          (and (> i 0)
               (begin
                 (get-x s)
                 (loop (1- i)))))))

             reply	other threads:[~2009-12-07 17:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-07 17:25 Ludovic Courtès [this message]
2009-12-08 23:08 ` SRFI-9 on top of raw structs Neil Jerram
2009-12-09  0:04   ` Ludovic Courtès
2009-12-09 23:28     ` Neil Jerram

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87skbmzofj.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).