This is the mail archive of the libstdc++@gcc.gnu.org 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]

Re: streambuf performance 200x


Nathan Myers wrote:
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.

Note that this is complicated by the requirements on strstreambuf.
This program must still return 0 (it currently fails with a non-0
exit status with libstdc++):

    #include <cstring>
    #include <strstream>

    int main ()
    {
        char buf[] = "abc";

        std::strstreambuf sb (buf, sizeof buf, buf);

        sb.freeze ();

        sb.sputc ('x');

        return std::strcmp (buf, "abc");
    }

Regards
Martin


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