From: Mikael Djurfeldt <mdj@kvast.blakulla.net>
Cc: Neil Jerram <neil@ossau.uklinux.net>, guile-devel@gnu.org
Subject: Re: goops and memoization
Date: Wed, 20 Nov 2002 22:11:31 -0500 [thread overview]
Message-ID: <xy7of8j4nx8.fsf@linnaeus.i-did-not-set--mail-host-address--so-tickle-me> (raw)
In-Reply-To: <Pine.GSO.4.05.10211201833410.18410-100000@sallust.ida.ing.tu-bs.de> (Dirk Herrmann's message of "Wed, 20 Nov 2002 19:11:20 +0100 (CET)")
First a disclaimer:
I added GOOPS to Guile because I needed an object system in my neural
simulator. I did not have infinite time to code, but I tried to focus
on at least getting the user-level definition reasonable so that we
would not build ourselves into a corner. I looked at many different
kinds of object systems when arriving at the current GOOPS.
That said, quite a lot of the code was developed during a few days a
certain Christmas, and parts of compile.scm was written on Arlanda
airport while waiting for boarding an aircraft. I urgently needed
someting working and planned to rewrite it later.
Well, later I judged it would serve people better to add the code to
the Guile source tree than letting people wait infinitely until my
rewrite would get high enough priority. I then tried to get
volunteers to rewrite the code in C.
While there are "dark corners" in GOOPS I still dare to claim that it
works on sound principles, works reliably and is probably one of the
most efficient Scheme object systems. Benchmarks show that GOOPS
method dispatch is negligible and a GOOPS generic function nearly as
efficient as an ordinary closure.
Dirk Herrmann <dirk@sallust.ida.ing.tu-bs.de> writes:
> This conflicts with goops: goops unmemoizes the function code, using
> 'procedure-source' (look into oop/goops/compile.scm). This will re-create
> the original code, including all the symbols that refer to local
> variables. This un-memoized code is then optimized in some way, and
> re-written into the closure object. Then, if the closure is evaluated, it
> is not run through the memoizer again (since it is already a closure).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Just a note: This is something which holds *after* your change, not previously.
> Now, if the executor runs over a symbol corresponding to a local variable,
> it will treat is as a symbol belonging to a global variable and try to
> find it within the module.
I'm sure Neil would find his way in the code, but since the answer
seems obvious to me because of my previous knowledge, I'll give some
hints:
A few notes on GOOPS method dispatch:
As in most CLOS-like systems, GOOPS method dispatch is quite advanced.
For example, a generic function application involves sorting the
applicable methods after specificity. We might in fact like to make
it even more advanced (adding support for singletons and type coercion
for example).
To get GOOPS fast, we cache the results of this involved process in a
"method cache" in the generic function. Next time a GF is applied to
the same set of argument types, the evaluator just makes a quick
lookup in the cache and can start to evaluate the method body without
delay. The format of the method cache is described in
oop/goops/dispatch.scm.
The procedure compile-method in oop/goops/compile.scm takes the sorted
list of applicable methods and a list of the argument types in the GF
application and returns a "cmethod", which is the tail of a method
cache entry:
CMETHOD ::= (CLOSURE-ENVIRONMENT FORMALS BODY-FORM1 ...)
Currently, compile-method only makes sure the method has a local
next-method binding (specific to this method cache entry) if that is
needed. However, there are plans to let it make powerful
optimizations of the code, with great potential of reducing overhead.
It seems to me that what you need to do is to run the tail of the
cmethod (BODY-FORM1 ...) through your memoizer. That should fix it.
In fact, as you see above, a cmethod contains the same information as
a closure.
Mikael
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next prev parent reply other threads:[~2002-11-21 3:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-16 13:41 goops and memoization Dirk Herrmann
2002-11-17 10:56 ` Neil Jerram
2002-11-20 18:11 ` Dirk Herrmann
2002-11-21 3:11 ` Mikael Djurfeldt [this message]
2002-11-21 3:28 ` Mikael Djurfeldt
2002-11-21 23:50 ` Neil Jerram
2002-11-22 1:08 ` Mikael Djurfeldt
2002-11-22 1:13 ` Mikael Djurfeldt
2002-11-24 9:41 ` Neil Jerram
2002-11-24 16:32 ` Mikael Djurfeldt
2002-11-21 20:31 ` Neil Jerram
2002-11-22 0:49 ` Mikael Djurfeldt
2002-11-29 22:48 ` Neil Jerram
2002-11-29 23:31 ` Neil Jerram
2002-11-21 20:36 ` Neil Jerram
2002-11-24 16:42 ` Dirk Herrmann
[not found] <Pine.GSO.4.05.10212011757340.18607-100000@sallust.ida.ing.tu-bs.de>
2002-12-01 18:00 ` Neil Jerram
2002-12-02 8:45 ` Mikael Djurfeldt
2002-12-02 9:14 ` Mikael Djurfeldt
2002-12-03 0:13 ` Lynn Winebarger
2002-12-03 7:59 ` Mikael Djurfeldt
2002-12-03 8:38 ` Tom Lord
2002-12-04 2:25 ` Mikael Djurfeldt
2002-12-04 2:49 ` Tom Lord
2002-12-03 17:17 ` Lynn Winebarger
2002-12-04 2:41 ` Mikael Djurfeldt
[not found] <Pine.GSO.4.05.10212021650410.21423-100000@sallust.ida.ing.tu-bs.de>
2002-12-04 1:53 ` Mikael Djurfeldt
2002-12-04 2:38 ` Tom Lord
2002-12-04 2:56 ` Rob Browning
[not found] <Pine.GSO.4.05.10212021836430.21423-100000@sallust.ida.ing.tu-bs.de>
2002-12-04 2:19 ` 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=xy7of8j4nx8.fsf@linnaeus.i-did-not-set--mail-host-address--so-tickle-me \
--to=mdj@kvast.blakulla.net \
--cc=djurfeldt@nada.kth.se \
--cc=guile-devel@gnu.org \
--cc=neil@ossau.uklinux.net \
/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).