[Top][All Lists]

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

Re: Unbuffered socket I/O

From: Ludovic Courtès
Subject: Re: Unbuffered socket I/O
Date: Wed, 07 Mar 2007 10:40:33 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)


Kevin Ryde <address@hidden> writes:

> Speaking of scm_getc ... I've wondered for a while if some of the low
> level reading funcs ought to be looking directly into the read buffer
> instead of making a call to scm_getc for every char.  My experience
> has usually been that a function call per character is very much to be
> avoided if performance on sizeable input matters.

You are right: `scm_getc ()' _is_ a performance bottleneck, one function
call for a single memory read (which is the common case when the port is
buffered) is way too much---`scm_getc ()' often shows up in the top 10
in Gprof's flat profile.

The whole point of having a buffer in a publicly-exposed struct is to
avoid function call overhead when accessing it.  Thus, `scm_getc ()'
should be inlined.

(You might have read that Guile-Reader is noticeably faster than
`scm_read ()'.  One of the reasons for this is that it inlines
`scm_getc ()' in the generated lightning code.)

Unfortunately, the machinery in `inline.h' makes it quite inconvenient
to add inline functions, and forces us to put all of them in a single
file.  GMP has a similar but slightly "cleaner" mechanism, which maybe
we could build upon to improve ours.

There are definitely a number of functions candidate for inlining in
Guile, typically functions that only execute a handful of instructions.


reply via email to

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