[Patch] Partial fix for libstdc++/15002

Paolo Carlini pcarlini@suse.de
Sun Apr 18 15:21:00 GMT 2004


Hi,

curious: I was already working on this issue when PR 15002 was submitted.

Anyway, this is a partial fix, a simple good improvement. For the testcase
presented - reading 200000 lines each one 200 chars long - with

    std::ifstream f("test.file");
    std::string l;
    while (std::getline(f, l));

on my P4-2400, -O2:

3.3.3
-----
5.130u 0.020s 0:05.15 100.0%    0+0k 0+0io 211pf+0w

mainline/3.4.0
--------------
3.000u 0.060s 0:03.06 100.0%    0+0k 0+0io 203pf+0w

patched
-------
1.140u 0.040s 0:01.19 99.1%     0+0k 0+0io 205pf+0w

The fix is not complete, we can do better, but rather general: I noticed
in the profile that we were spending most of the time in memset, whereas
for all the single char modifying algorithms we had better just assigning
the char. All the single char modifying algorithms take advantage of this
tweak, for instance performance/21_strings/string_append.cc becomes about
2.5 times faster.

Tested x86-linux.

Paolo.

/////////////////////
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_15002
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040418/c4ab2a98/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_15002
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20040418/c4ab2a98/attachment-0001.ksh>


More information about the Libstdc++ mailing list