[Top][All Lists]

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

Re: [Chicken-users] date comparison is very, very, very slow (srfi-19)

From: Alaric Snell-Pym
Subject: Re: [Chicken-users] date comparison is very, very, very slow (srfi-19)
Date: Fri, 26 Sep 2008 00:06:34 +0100

Hash: SHA1

2) Record accessors in Chicken (and all Scheme
implementations to my knowledge) are slow - they're not just
memory references, but full procedures, and so every
reference to every date field (all 8 of them) generates a
generic procedure call with stack checking and all.

I've always wanted to fix this.

The problem is that you really want inlining.

This is macro-like behaviour, but if you made accessors macros, then
things would fall apart as soon as you tried to map them across a
list of structures to get a list of elements, etc etc... they're no
longer functions, even though they look like them.

One approach is just to implement inlining: when (foo ...) is
encountered, if the compiler can be sure exactly which lambda 'foo'
refers to using the usual constant-propagation and set!-spotting
techniques (to detect run-time mutable bindings that are nontrivial
to analyse), to inline it there and then (subject to a size limit and
avoidance of endless recursive expansions... although unrolling a
recursive loop a few times is no bad thing).

Or perhaps something more general and interesting, such as allowing
lambdas to have attached "macro-like hints"; sort of a macro attached
to the lambda, which is called when an invocation of the lambda is
unambiguously found and gets to treat it in a macro-like way. With
the explicit guarantee that the implementation may well ignore it due
to the vagaries of inferring lambdas, so you'd better only use it for
semantic-preserving performance-enhancing tricks such as statically
converting '(* 1 n)' to 'n', '(* 2 3) to '6', that sort of thing.


- --
Alaric Snell-Pym

Version: GnuPG v1.4.8 (Darwin)


reply via email to

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