This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

streambuf performance 200x

It's time to talk about fixing core streambuf performance.  As it 
is, when last I measured, IIRC, it was over two orders of magnitude 
slower than stdio.   We need to do something about that before we 
commit to a long period of frozen ABI.

To accomplish this, we have to have absolutely minimal, inline
implementations of basic_streambuf::sputc and sgetc.  All the
complications have to go, so that, e.g., sputc expands to the machine 
equivalent of something very like

   (this->pp != this->ep) ? (*this->pp++ = c) : this->overflow(c);

and correspondingly for sgetc.

How do we keep this compatible with things like filebuf, where the get 
and put pointers are supposed to be the same.  The trick is that we
must keep one set of the get or the put pointers such that p == e. 
Then, overflow and underflow get called if the last operation was
a get or put (respectively), and they set things up for further puts 
or gets (respectively), by copying the p and the g pointer sets back 
and forth.

I think we can radically simplify the code at the same time as we
gain back the two orders of magntude in performace that we lost.
I don't know how this will play with libio interchangeability, but 
I think people would trade a lot for it.

Nathan Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]