[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SRFI-9 on top of raw structs

From: Ludovic Courtès
Subject: SRFI-9 on top of raw structs
Date: Mon, 07 Dec 2009 18:25:36 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)


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 to Andy for pointing it out!

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

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

(define s (make-foo 1))

(define n 7000000)

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

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]