11722 – [3.4 only] Unbuffered filebuf::sgetn is slow (original) (raw)

Description Pétur Runólfsson 2003-07-30 09:06:53 UTC

This is the same as 11378, but for input this time. The problem is the same: basic_filebuf::xsgetn calls read for each character, but fread_unlocked calls read only once.

Comment 1 Pétur Runólfsson 2003-07-30 09:10:34 UTC

Created attachment 4520 [details] Program for comparing unbuffered input performance.

Here are typical results:

time ./inspeed stdio 1000000 10 0.75user 1.36system 0:02.19elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (92major+12minor)pagefaults 0swaps time ./inspeed iostream 1000000 10 7.93user 12.44system 0:21.04elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (94major+12minor)pagefaults 0swaps

This shows that when reading 10 characters at a time, filebuf::sgetn is 10x slower than fread_unlocked.

Comment 2 Drea Pinski 2004-01-14 03:16:45 UTC

Is this a regression, if not move the target.

Comment 3 Pétur Runólfsson 2004-01-15 09:49:57 UTC

Is this a regression

No. Unbuffered input doesn't work at all with any 3.x release, and 2.95.3 is just as bad as current mainline.

Comment 4 Paolo Carlini 2004-01-15 09:52:57 UTC

... still, I want to fix this before 3.4.0, since the changes are straightforward in the light of the corresponding fix for sputn...

Comment 5 Mark Mitchell 2004-06-12 22:57:14 UTC

Postponing until 3.4.2. Paolo, it's OK if you want to check in a patch for this before 3.4.1, but I'm not going to hold the release for it.

Comment 6 Mark Mitchell 2004-08-29 18:55:10 UTC

Postponed until GCC 3.4.3.

Comment 9 Paolo Carlini 2004-09-19 11:28:42 UTC

Fixed for 3.4.3.