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: libstdc++/4150: catastrophic performance decrease in C++ code


> 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".

Hi Jason,

Thank you for assigning this PR to yourself.  A long time ago,
Benjamin wrote publicly to the libstdc++ list that this performance
situation could be improved by *any* patch that broke zero test cases.
There are also a number of interactive cases not well represented in
the test suite.

The _GLIBCPP_AVOID_FSEEK code path was the screwdriver (originally
designed to avoid portability issues with the seeking; nothing to do
with performance; as a side-effect, I noticed that it improved
performance on my platform and honestly thought it might for Linux as
well); you whipped out the hammer with your patch. ;-)

Having attempted patches similar to your proposal, I think the hammer
breaks those test cases that exercise interleaving between C and C++ IO.

I believe that the hammer can be used for any stream that is not
sync'd to C stdio (according to section 27.4.2.4, only the 8 standard
streams mentioned in section 27.3 need ever be so sync'd).  Thus, when
sync_with_stdio(false) has been called, all streams should get your
proposed code path.  All streams not explicitly named in 27.3
(i.e. those created by users) may always use your proposed code path.
Any standard stream that is so sync'd must used the existing code path
(or some improvement you dream up) or else you break test cases
inspired by the standard.

Regards,
Loren
-- 
Loren J. Rittle
Senior Staff Software Engineer, Distributed Object Technology Lab
Networks and Infrastructure Research Lab (IL02/2240), Motorola Labs
rittle@rsch.comm.mot.com, KeyID: 2048/ADCE34A5, FDC0292446937F2A240BC07D42763672


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