public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: Re: libstdc++/4150: catastrophic performance decrease in C++ code Date: Sun, 14 Apr 2002 19:36:00 -0000 [thread overview] Message-ID: <20020415023600.14816.qmail@sources.redhat.com> (raw) The following reply was made to PR libstdc++/4150; it has been noted by GNATS. From: Jason Merrill <jason@redhat.com> To: libstdc++@gcc.gnu.org Cc: gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/4150: catastrophic performance decrease in C++ code Date: Mon, 15 Apr 2002 03:25:59 +0100 --=-=-= Loren suggested defining _GLIBCPP_AVOID_FSEEK as a fix for 4150; I've tried it. It avoids the useless seeks for the stdin case, but it's a rather Pyrrhic improvement; it also slows down execution from 0:42 to 1:50 (vs 0:20 in 2.95). The comment in ios.cc says that this "hurts" performance; I would suggest that verb isn't strong enough. Perhaps "eviscerates". But going back to the problem without that define, the basic bug seems to be that after basic_filebuf::underflow() reads in a chunk of data, it then always rewinds the file to the beginning of that chunk. The next time it gets called, it seeks ahead to the end of that chunk to read the next one. And so on. So we get two useless seeks between each read. There may be a point to these seeks, but there are no comments in the code to justify them. Simply tearing them out brings us up to 2.95 performance levels. At least seekoff would need to be adjusted accordingly, but is there any reason why we can't leave the file pointer at the end of the last read block, rather than at the beginning as we do now? Jason --=-=-= Content-Type: text/x-patch Content-Disposition: inline *** include/bits/fstream.tcc.~1~ Fri Apr 12 11:28:30 2002 --- include/bits/fstream.tcc Mon Apr 15 02:49:14 2002 *************** namespace std *** 268,280 **** { if (__testout) _M_really_overflow(); ! #if _GLIBCPP_AVOID_FSEEK ! else if ((_M_in_cur - _M_in_beg) == 1) ! _M_file->sys_getc(); ! #endif ! else ! _M_file->seekoff(_M_in_cur - _M_in_beg, ! ios_base::cur, ios_base::in); } if (__testinit || __testget) --- 268,275 ---- { if (__testout) _M_really_overflow(); ! if (_M_in_cur < _M_in_end) ! abort (); } if (__testinit || __testget) *************** namespace std *** 316,331 **** if (__testout) _M_out_cur = _M_in_cur; __ret = traits_type::to_int_type(*_M_in_cur); - #if _GLIBCPP_AVOID_FSEEK - if (__elen == 1) - _M_file->sys_ungetc(*_M_in_cur); - else - { - #endif - _M_file->seekoff(-__elen, ios_base::cur, ios_base::in); - #if _GLIBCPP_AVOID_FSEEK - } - #endif } } } --- 311,316 ---- --=-=-=--
next reply other threads:[~2002-04-15 2:36 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-04-14 19:36 Jason Merrill [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-04-23 5:23 jason 2002-04-18 4:06 Jason Merrill 2002-04-18 3:06 Jason Merrill 2002-04-17 21:56 Benjamin Kosnik 2002-04-17 19:26 Jason Merrill 2002-04-16 5:46 Jason Merrill 2002-04-15 16:16 Jason Merrill 2002-04-15 7:42 jason 2002-04-14 11:13 jason 2002-04-11 18:20 ljrittle 2002-04-11 17:19 rth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20020415023600.14816.qmail@sources.redhat.com \ --to=jason@redhat.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).