[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-10 Thread paolo dot carlini at oracle dot com
--- Comment #25 from paolo dot carlini at oracle dot com 2010-09-10 16:01 --- Good. Please give me a couple of days to come to your code. Note, since you don't have a Copyright Assignment on file, it will be difficult to fully acknowledge your work in the ChangeLog. Thus, I would sugges

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-10 Thread tstarling at wikimedia dot org
--- Comment #24 from tstarling at wikimedia dot org 2010-09-10 15:25 --- Created an attachment (id=21766) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21766&action=view) dynamic_cast<> hack The attached patch uses a dynamic_cast<> hack to avoid the need to break the ABI. I added

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread tstarling at wikimedia dot org
--- Comment #23 from tstarling at wikimedia dot org 2010-09-10 00:17 --- (In reply to comment #21) > Anyway, not sure which STL getline we are talking about here, because e.g. > src/istream.cc getline seems to access the stdio buffer directly: > streamsize __size = std

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread paolo dot carlini at oracle dot com
--- Comment #22 from paolo dot carlini at oracle dot com 2010-09-09 16:08 --- Jakub, when, by default, cin & co boil down to stdio_sync_filebuf, the underlying basic_streambuf is unbuffered, everything is unbuffered in the C++ library. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread jakub at gcc dot gnu dot org
--- Comment #21 from jakub at gcc dot gnu dot org 2010-09-09 15:07 --- #if __GNUC__ >= 3 # define _IO_BE(expr, res) __builtin_expect ((expr), res) #else # define _IO_BE(expr, res) (expr) #endif #define _IO_getc_unlocked(_fp) \ (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end,

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread paolo dot carlini at oracle dot com
--- Comment #20 from paolo dot carlini at oracle dot com 2010-09-09 14:53 --- Good about POSIX, we would add a configure time test with some hope to enable the mechanism outside Linux too. Anyway, I'm sure your kind of loop would improve the performance a lot - if only we could have it

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread tstarling at wikimedia dot org
--- Comment #19 from tstarling at wikimedia dot org 2010-09-09 14:28 --- (In reply to comment #16) > The *_unlocked versions are faster a lot actually, at least for the one > character ops, because no locking is performed and the calls are inlined. > But the question is whether libstdc+

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread tstarling at wikimedia dot org
--- Comment #18 from tstarling at wikimedia dot org 2010-09-09 14:12 --- Created an attachment (id=21752) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21752&action=view) gprof output I haven't managed to get libstdc++ to compile with -pg, but compiling the test program with -sta

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread paolo dot carlini at oracle dot com
--- Comment #17 from paolo dot carlini at oracle dot com 2010-09-09 10:42 --- At some point I tried quickly replacing some getc, did notice an improvement of course, but of the order of magnitude I mentioned. Worth further investigating sure (and simple, just replace in stdio_sync_ and

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread jakub at gcc dot gnu dot org
--- Comment #16 from jakub at gcc dot gnu dot org 2010-09-09 10:33 --- The *_unlocked versions are faster a lot actually, at least for the one character ops, because no locking is performed and the calls are inlined. But the question is whether libstdc++ can use them, unless there is som

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-09 Thread paolo dot carlini at oracle dot com
--- Comment #15 from paolo dot carlini at oracle dot com 2010-09-09 09:25 --- If you write a patch it would be of course looked at. But *please* try first something that doesn't break the ABI, because we have *no* idea when you changes would be applied otherwise. About the *_unlocked fu

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-08 Thread tstarling at wikimedia dot org
--- Comment #14 from tstarling at wikimedia dot org 2010-09-09 02:31 --- (In reply to comment #11) > So? We are not changing glibc here. The C++ library does *not* use buffering > in > the synced mode, and it does otherwise, for fstreams in particular. Where do > you think the performa

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-08 Thread jakub at gcc dot gnu dot org
--- Comment #13 from jakub at gcc dot gnu dot org 2010-09-08 14:48 --- And, getdelim insist on allocating resp. reallocating the buffer. That is of course usually desirable when used from C, but I'm afraid it isn't in this case, where you have user provided buffer with fixed size. You

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-08 Thread paolo dot carlini at oracle dot com
--- Comment #12 from paolo dot carlini at oracle dot com 2010-09-08 10:20 --- By the way, getdelim is not standard, thus would work only on linux, even more special casing. More importantly, fgets *stores* newline and '\0', at variance with getline, I don't think it can be used as-is as

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-08 Thread paolo dot carlini at oracle dot com
--- Comment #11 from paolo dot carlini at oracle dot com 2010-09-08 09:59 --- (In reply to comment #8) > But a 9-10x difference doesn't sound reasonable to me. The synced mode is not > unbuffered, before or after my suggested change, it uses the internal buffer > in > glibc. So? We ar

[Bug libstdc++/45574] cin.getline() is extremely slow

2010-09-08 Thread paolo dot carlini at oracle dot com
--- Comment #10 from paolo dot carlini at oracle dot com 2010-09-08 09:56 --- (In reply to comment #8) > Maybe you should tell that to Paolo Carlini, who closed bug 15002 as "resolved > fixed" in 2004, And it *is* fixed. Did you actually open the testcases? Just plain fstreams, thus no