[Issue 3763] std.stdio.readlnImpl absurdly inefficient

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Feb 1 20:37:43 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3763



--- Comment #2 from David Simcha <dsimcha at yahoo.com> 2010-02-01 20:37:40 PST ---
Well, the problem is pretty clear.  It's in std.stdio.readlnImpl().  In the
unbuffered I/O routine in the DIGITAL_MARS_STDIO version block, we basically do
the following in pseudocode:

buf = readNext64Bytes();
buf ~= readRest();  // Recurse.

We're effectively prepending to our result in 64-byte increments.  Therefore,
buf is reallocated once for every 64 bytes once we hit unbuffered I/O.  Also
note that the use of O(N) stack space causes stack overflows for very long
lines (around 700 KB+).

The problem is that, from looking at the rest of the code, all the other
routines for different OS's and I/O libs are implemented the obvious way, using
plain old array appending, which makes me believe that this one is different
for a (unknown to me and probably relatively obscure) reason.  Why was the
unbuffered I/O routine in the DIGITAL_MARS_STDIO version block coded in such an
odd way in the first place?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list