public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Theodore.Papadopoulo@sophia.inria.fr
To: gcc-gnats@gcc.gnu.org
Subject: libstdc++/2211: Performance regression for cin.read with respect to g++-2.95.2 ?
Date: Sun, 01 Apr 2001 00:00:00 -0000	[thread overview]
Message-ID: <20010307191657.8381.qmail@sourceware.cygnus.com> (raw)

>Number:         2211
>Category:       libstdc++
>Synopsis:       Performance regression for cin.read with respect to g++-2.95.2 ?
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 07 11:26:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Theo Papadopoulo
>Release:        unknown-1.0
>Organization:
>Environment:
g++ mainline from 01/22/2001
Linus redhat 6.2 on x86 (P III)
>Description:
I have a huge performance problem with a call to a libstdc++-v3 
function. istream::read. This is true only for I/O done with cin.

mururoa->ls -l toto
-rw-r--r--   1 papadop  robotvis  1367160 Mar  7 11:38 toto
mururoa->cat toto toto | ./a.out ~/Robotvis++/Libs/Image/tests/images/scully.float.inr
Before ifstream::read: 983970673
After ifstream::read: 983970673
Before cin.read: 983970673
After cin.read: 983970682
Before fread: 983970682
After fread: 983970682

With g++-2.95.2, I get:
mururoa->/usr/local/bin/g++ -g -pg -ftemplate-depth-30 -fPIC -DPIC Test.C
mururoa->cat toto toto | ./a.out ~/Robotvis++/Libs/Image/tests/images/scully.float.inr
Before ifstream::read: 983978303
After ifstream::read: 983978303
Before cin.read: 983978303
After cin.read: 983978303
Before fread: 983978303
After fread: 983978303

[regression 2.95.2 was cin.read(ing) as that as the other ways 
of reading]

The crux of the problem seem to be (in fstream.tcc).

	  // XXX So that istream::getc() will only need to get 1 char,
	  // as opposed to BUF_SIZE.
	  if (__fd == 0)
	    _M_buf_size = 1;

Consequently, characters are read one by one which is extremely 
costly.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="Test.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Test.C"

I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPHN0ZGlvLmg+
CiNpbmNsdWRlIDx0aW1lLmg+CgppbnQKbWFpbihpbnQgYXJnYyxjaGFyICphcmd2W10pCnsKICAg
IGNvbnN0IHVuc2lnbmVkIGRhdGFfc2l6ZSA9IDEzNjcxNjA7CiAgICBjaGFyIGRhdGFbZGF0YV9z
aXplXTsKCiAgICBzdGQ6Omlmc3RyZWFtIGlmcyhhcmd2WzFdKTsKCiAgICBzdGQ6OmNlcnIgPDwg
IkJlZm9yZSBpZnN0cmVhbTo6cmVhZDogIiA8PCB0aW1lKDApIDw8IHN0ZDo6ZW5kbDsKICAgIGlm
cy5yZWFkKGRhdGEsZGF0YV9zaXplKTsKICAgIHN0ZDo6Y2VyciA8PCAiQWZ0ZXIgaWZzdHJlYW06
OnJlYWQ6ICIgPDwgdGltZSgwKSA8PCBzdGQ6OmVuZGw7CgogICAgc3RkOjpjZXJyIDw8ICJCZWZv
cmUgY2luLnJlYWQ6ICIgPDwgdGltZSgwKSA8PCBzdGQ6OmVuZGw7CiAgICBzdGQ6OmNpbi5yZWFk
KGRhdGEsZGF0YV9zaXplKTsKICAgIHN0ZDo6Y2VyciA8PCAiQWZ0ZXIgY2luLnJlYWQ6ICIgPDwg
dGltZSgwKSA8PCBzdGQ6OmVuZGw7CgogICAgc3RkOjpjZXJyIDw8ICJCZWZvcmUgZnJlYWQ6ICIg
PDwgdGltZSgwKSA8PCBzdGQ6OmVuZGw7CiAgICBmcmVhZChkYXRhLDEsZGF0YV9zaXplLHN0ZGlu
KTsKICAgIHN0ZDo6Y2VyciA8PCAiQWZ0ZXIgZnJlYWQ6ICIgPDwgdGltZSgwKSA8PCBzdGQ6OmVu
ZGw7Cn0K


             reply	other threads:[~2001-04-01  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-01  0:00 Theodore.Papadopoulo [this message]
2001-06-26 17:19 bkoz
2002-01-27 15:27 rodrigc

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=20010307191657.8381.qmail@sourceware.cygnus.com \
    --to=theodore.papadopoulo@sophia.inria.fr \
    --cc=gcc-gnats@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: link
Be 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).