unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: mikael@djurfeldt.com
Cc: "Ludovic Courtès" <ludo@gnu.org>, guile-devel@gnu.org
Subject: Re: fixes to goops + light structs + 'u' slots
Date: Wed, 16 Apr 2008 00:22:29 +0200	[thread overview]
Message-ID: <m37iey4v2y.fsf@pobox.com> (raw)
In-Reply-To: <66e540fe0804131209y6a3a1810i72a6ba048a7cb83b@mail.gmail.com> (Mikael Djurfeldt's message of "Sun, 13 Apr 2008 21:09:06 +0200")

On Sun 13 Apr 2008 21:09, "Mikael Djurfeldt" <mikael@djurfeldt.com> writes:

> At least given the state of Guile at the point when
> GOOPS accessors were implemented, the current imlementation was
> superior to both a slot-ref-based and a SMOB-based implementation.
[...]
> In any case, *please* always benchmark changes like this against previous code.

So, I was curious about this. I made four very simple tests:

accessor set:  (set! (bar instance) 3)
accessor ref:  (bar instance)
slot-set!:     (slot-set! instance 'bar 3)
slot-ref:      (slot-ref instance 'bar)

Where instance is defined as:
(define-class <cls> () (bar #:accessor bar))
(define instance (make <cls>))

I then ran the tests in that order in the order given, within this loop:

    (time (do ((i 1 (1+ i))) ((> i 1000000))  ... ))

That's the time macro from (ice-9 time).

These are my results on my Core2 Duo laptop, fixed to 800 mhz, against
the latest guile 1.8 and 1.6. The "baseline" is the do loop without any
test at all:

                   user time
               1.6          1.8
--------------+----------------------
baseline      |1.67s        1.97s
accessor set  |2.66s        3.90s
accessor ref  |2.61s        3.79s
slot-set!     |2.58s        3.80s
slot-ref      |2.23s        3.15s

I then ran accessor ref tests on objects that necessarily had their slots
bound, and thus would go through @assert-bound-ref:

(define-class <cls2> () (baz #:accessor baz #:init-value 3))
(define instance2 (make <cls2>))

                   user time
               1.6          1.8
--------------+----------------------
accessor ref  |2.22s        3.00s

Note the scale is that a single ref translates to 1 or 2 microseconds,
and this with the clock scaled back significantly. By way of comparison,
a 1000000-time ref loop in python took 0.52s, a set loop took 0.59s, and
a noop loop took 0.18s.

Conclusions:

  (1) 1.8 is slower than 1.6. (We knew that.)
  (2) The speed ordering is the same on 1.8 and 1.6:
      slot-ref < accessor ref
      slot-set! < accessor set
  (3) If the determination can be made that the slot will never be
      unbound, and we compile to the @assert-bound-ref case, then
      accessor refs are indeed faster than slot-ref.
  (4) In this particular test, guile is slower than python

I would speculate, Mikael, that it is case (3) that you are recalling.

Andy
-- 
http://wingolog.org/




  parent reply	other threads:[~2008-04-15 22:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-09 23:45 fixes to goops + light structs + 'u' slots Andy Wingo
2008-04-10 21:33 ` Ludovic Courtès
2008-04-10 23:42   ` Andy Wingo
2008-04-13 18:47     ` Ludovic Courtès
2008-04-13 19:09       ` Mikael Djurfeldt
2008-04-13 20:42         ` Ludovic Courtès
2008-04-14 21:45         ` Andy Wingo
2008-04-14 22:16           ` Mikael Djurfeldt
2008-04-19 16:28             ` Andy Wingo
2008-04-19 23:07               ` Mikael Djurfeldt
2008-04-20 10:46                 ` Andy Wingo
2008-04-14 22:20           ` Mikael Djurfeldt
2008-04-15 22:22         ` Andy Wingo [this message]
2008-04-16  6:34           ` Mikael Djurfeldt
2008-04-16  6:52             ` Mikael Djurfeldt

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=m37iey4v2y.fsf@pobox.com \
    --to=wingo@pobox.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    --cc=mikael@djurfeldt.com \
    /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).