mit-scheme-devel
[Top][All Lists]
Advanced

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

Re: [MIT-Scheme-devel] two changes to push


From: Joe Marshall
Subject: Re: [MIT-Scheme-devel] two changes to push
Date: Sun, 20 Sep 2009 12:14:51 -0700

On Sat, Sep 19, 2009 at 9:50 PM, Taylor R Campbell <address@hidden> wrote:
>
>   For SYMBOL?, I thought it was worth integrating because
>   GUARANTEE-SYMBOL is called on nearly every I/O operation.
>
> It is?  I don't see why it would, unless you are changing a generic
> port's line-ending or using port properties at every I/O operation.

I'm guessing it was an unforseen consequence.  Here's what happens:

When reading or writing a string or character, a call is made to
TRANSCRIBE-CHAR or TRANSCRIBE-SUBSTRING which echoes
the character or string to the transcription port, if one exists.  In order
to check for a transcription port, these routines call PORT/TRANSCRIPT
which either returns the transcription port or #F if there isn't one.
PORT/TRANSCRIPT calls PORT/GET-PROPERTY which has this
definition:

(define (port/get-property port name default)
  (guarantee-symbol name 'PORT/GET-PROPERTY)
  (let ((p (assq name (port/properties port))))
    (if p
        (cdr p)
        default)))

So you get an out-of-line call to GUARANTEE-SYMBOL and ASSQ on each
I/O operation.

I think moving the transcript port from the property list to the port
itself would be worthwhile because this call chain happens a lot.  It
would make ports a little bit bigger, but I don't think that's enough
to worry about.

Alternatively, these two things would help:  have a version of port/get-property
that didn't GUARANTEE-SYMBOL.  (If the key isn't a symbol, it won't be
found anyway), and do a quick check on the port/properties to see if it
is NULL? before calling out to ASSQ. (This would avoid a call on the common
case of ports without properties.)

It'd be great to fix these up because port operations are one of the big
time sinks for SF.

-- 
~jrm




reply via email to

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