[gambit-list] Parameter objects performance Q

Adam adam.mlmb at gmail.com
Sun Mar 8 11:26:41 EDT 2020

Hi Marc,

Cool, wonderful!

Yeah for any situation like

(define (a)
  ; Teleport from hr
(define (b) (c))
(define (c)
  ; Teleport to hr

, just totally great.

Your subsequent email re. "(make-timeout-handler 5 (lambda () …))))"
usecase and "I think that is a better API." comment I believe I fully agree
with, also that's neat, it illustrates how this is useful on the
runtime-interacts-with-userland level.

Thinking back, all my parameter objects until now have been global
variables. This also means that, for a given sourcecode file, the number of
parameter objects has been pre-specified. In this kind of usage situation,
would any optimization trick be possible? E.g. could the "current input
port or one of the last 3 accessed parameters" set be extended with a copy
of each of that fixed set of toplevel parameter objects and so accordingly
their parameterization and access be O(1) always.

(This email was primarily to learn what kind of time characteristics
parameterized objects have, given how great they are.)


On Sun, 8 Mar 2020 at 23:00, Marc Feeley <feeley at iro.umontreal.ca> wrote:

> The dynamic environment is implemented as a hybrid structure that combines
> a dictionary (implemented as a binary tree), with a special case for the
> frequently accessed parameters (current-input-port, etc), and a cache of
> the last 3 parameters that were accessed.
> So if you access the current input port or one of the last 3 accessed
> parameters, the time complexity is O(1).  Otherwise it is O(log N) where N
> is the number of bindings in the environment.
> I may change the binary tree to a table once the functional API to tables
> is fully implemented.
> So I think the complexity is pretty good, but obviously much slower than
> an access to a lexical variable.  I’ll let you do some benchmarking to
> determine the hidden constant.
> Marc
> > On Mar 8, 2020, at 10:44 AM, Adam <adam.mlmb at gmail.com> wrote:
> >
> > Hi Marc,
> >
> > I can't recall if this is somewhere in the mailing list archive from
> before:
> >
> > I recall that you indicated that parameter objects are expensive.
> >
> > Would you mind describing/quantifying the average/worst case/best case
> cost for assigning a value to a parameter object by parameterization
> (|parameterize|), and for accessing a parameter object (load or store
> operation by invoking it as a closure)?
> >
> > Parameter objects are very practical and have ample use scenarios, both
> high-level and relatively low-level.
> >
> > Thanks,
> > Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20200308/b0638cc2/attachment.htm>

More information about the Gambit-list mailing list