From: Daniel Kraft <d@domob.eu>
To: Ken Raeburn <raeburn@raeburn.org>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: Elisp performance
Date: Fri, 31 Jul 2009 07:15:17 +0200 [thread overview]
Message-ID: <4A727DE5.8070604@domob.eu> (raw)
In-Reply-To: <3A3F4045-BDAB-4A8F-B003-E366EAC2C03F@raeburn.org>
Ken Raeburn wrote:
>> Obviously, it would help a lot to do so. On the other hand, switching
>> to primitive-ref's would help even more, but I fear we can not easily
>> do so, because we can not know if a symbol targets a primitive or was
>> rebound at compile time... BTW, a quick test with Scheme:
>> [....]
>> So it seems that the Scheme compiler just ignores this possibility...
>> Is (set! + ...) and expecting (+ 1 2) to change invalid, or should
>> this strictly be regarded as a bug?
>
> In general I don't think you can assume it for all symbols, but if it
> helps, the Emacs byte-compiler also assumes that "+" and "cons" and
> certain other functions won't be redefined. It's even got an "add1"
> opcode.
>
> So if I understand right, if you make similar assumptions and change how
> function bindings are handled, your performance for this code drops to
> under a second? It sounds like maybe you can get within shouting
> distance of Emacs's own performance already, at least for certain test
> cases.
Well, that's partially true. For those built-ins that map directly to
Guile primitives, it would probably be an advantage to build
make-primitive-ref's for the generated TreeIL code directly; I'm not
sure if that's done at the moment, but in the future this will help for
things like optimization and special op-codes (e.g. add1).
I think it would really be reasonable to assume certain symbols don't
get rebound, if they don't have a different lexical binding at the
moment; although I think that the concept of dynamic binding is actually
also about the ability to rebind even built-ins to allow for changes...
For instance, what if I wanted to write a program that evaluates the
"efficiency" of some numerical algorithm by overloading + and * to count
the number of operations performed? This seems like a valid need to me
(in fact, I might be doing something similar for my Bachelor's thesis;
though probably not in Scheme or elisp, so this does not directly matter
here).
So my idea was to provide a compiler option to always use an ordinary
function call for certain or all primitives as a compromise; that sounds
like a quite good idea to me catering for both needs.
However, as a side-note: I don't think my code would drop below one
second if this was implemented (hm, at least I'm not sure), because for
instance all built-ins returning booleans (like < in the example) can
not map directly to Guile primitives because I need to translate #f to
%nil inbetween... It's a pity because comparisons are probably quite
common especially in such loops, but if we don't want to get rid of
translation and don't care about #f in elisp (see my other post in the
%nil thread), I see no way around this.
> Would this interfere with possibly blending Scheme GOOPS code with Elisp
> someday? Or is the generic support there at a lower level than this?
> (E.g., a "marker" object holds a buffer handle, possibly nil, and an
> offset that automatically gets adjusted if text is inserted before it.
> You can use "(+ 1 marker)" and get back an integer one greater than the
> marker's current offset. If markers were implemented using GOOPS, would
> this use of "+" work, given the changes you're suggesting?)
To be honest, I've nearly no idea about GOOPS so far and thus can't
comment here...
Yours,
Daniel
--
Done: Arc-Bar-Cav-Ran-Rog-Sam-Tou-Val-Wiz
To go: Hea-Kni-Mon-Pri
next prev parent reply other threads:[~2009-07-31 5:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-29 12:50 Elisp performance Daniel Kraft
2009-07-30 3:23 ` Ken Raeburn
2009-07-31 5:15 ` Daniel Kraft [this message]
2009-08-04 15:51 ` Andy Wingo
2009-07-30 20:18 ` Neil Jerram
2009-07-30 23:54 ` Ken Raeburn
2009-07-31 6:09 ` Daniel Kraft
2009-08-04 10:26 ` Andy Wingo
2009-08-04 10:26 ` Andy Wingo
2009-07-31 6:02 ` Daniel Kraft
2009-07-31 9:59 ` Ken Raeburn
2009-07-31 15:14 ` Daniel Kraft
2009-08-04 11:14 ` Andy Wingo
2009-08-04 11:00 ` Andy Wingo
2009-08-08 22:15 ` Ludovic Courtès
2009-08-04 10:17 ` Andy Wingo
2009-08-04 10:54 ` Daniel Kraft
2009-08-04 15:58 ` Ken Raeburn
2009-08-04 15:47 ` Andy Wingo
2009-08-04 16:12 ` Ken Raeburn
2009-08-04 19:28 ` Andy Wingo
2009-08-04 16:17 ` Daniel Kraft
2009-08-04 19:25 ` Andy Wingo
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=4A727DE5.8070604@domob.eu \
--to=d@domob.eu \
--cc=guile-devel@gnu.org \
--cc=raeburn@raeburn.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).