Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

The biggest difference between time and space is that you can't reuse time. -- Merrick Furst


devel / comp.lang.c / Re: Why does C allow structs to have a tag?

SubjectAuthor
* Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?David Brown
|`* Re: Why does C allow structs to have a tag?Thiago Adams
| `- Re: Why does C allow structs to have a tag?David Brown
+- Re: Why does C allow structs to have a tag?Öö Tiib
+* Re: Why does C allow structs to have a tag?Bart
|+* Re: Why does C allow structs to have a tag?Kaz Kylheku
||+- Re: Why does C allow structs to have a tag?Bart
||`* Re: Why does C allow structs to have a tag?Manfred
|| `* Re: Why does C allow structs to have a tag?David Brown
||  `* Re: Why does C allow structs to have a tag?Bart
||   +- Re: Why does C allow structs to have a tag?Richard Harnden
||   +* Re: Why does C allow structs to have a tag?Keith Thompson
||   |+* Re: Why does C allow structs to have a tag?Bart
||   ||+- Re: Why does C allow structs to have a tag?Keith Thompson
||   ||`* Re: Why does C allow structs to have a tag?James Harris
||   || `- Re: Why does C allow structs to have a tag?Bart
||   |`* Re: Why does C allow structs to have a tag?Manfred
||   | `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |  `* Re: Why does C allow structs to have a tag?Bart
||   |   +* Re: Why does C allow structs to have a tag?David Brown
||   |   |`- Re: Why does C allow structs to have a tag?Bart
||   |   `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |    `- Re: Why does C allow structs to have a tag?Malcolm McLean
||   `* Re: Why does C allow structs to have a tag?David Brown
||    `* Re: Why does C allow structs to have a tag?Bart
||     +* Re: Why does C allow structs to have a tag?David Brown
||     |`* Re: Why does C allow structs to have a tag?Bart
||     | `* Re: Why does C allow structs to have a tag?Malcolm McLean
||     |  `* Re: Why does C allow structs to have a tag?Bart
||     |   `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |    `* Re: Why does C allow structs to have a tag?Bart
||     |     +- Re: Why does C allow structs to have a tag?James Harris
||     |     `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |      `* Re: Why does C allow structs to have a tag?Bart
||     |       `* Re: Why does C allow structs to have a tag?Keith Thompson
||     |        `* Re: Why does C allow structs to have a tag?Bart
||     |         `- Re: Why does C allow structs to have a tag?Keith Thompson
||     `* Re: Why does C allow structs to have a tag?James Harris
||      `- Re: Why does C allow structs to have a tag?Bart
|`- Re: Why does C allow structs to have a tag?Keith Thompson
+* Re: Why does C allow structs to have a tag?Kaz Kylheku
|`* Re: Why does C allow structs to have a tag?Bart
| `- Re: Why does C allow structs to have a tag?James Harris
+- Re: Why does C allow structs to have a tag?James Kuyper
+* Re: Why does C allow structs to have a tag?Richard Damon
|`- Re: Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?Joe Pfeiffer
|`* Re: Why does C allow structs to have a tag?Malcolm McLean
| +* Re: Why does C allow structs to have a tag?Guillaume
| |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||`* Re: Why does C allow structs to have a tag?Bart
| || `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||  `* Re: Why does C allow structs to have a tag?Bart
| ||   `- Re: Why does C allow structs to have a tag?Keith Thompson
| |`* Re: Why does C allow structs to have a tag?James Kuyper
| | `* Re: Why does C allow structs to have a tag?Bart
| |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   +* Re: Why does C allow structs to have a tag?Bart
| |   |`* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   | `* Re: Why does C allow structs to have a tag?Bart
| |   |  `* Re: Why does C allow structs to have a tag?David Brown
| |   |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    +* Re: Why does C allow structs to have a tag?David Brown
| |   |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    | `* Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +* Re: Why does C allow structs to have a tag?Manfred
| |   |    |  |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +- Re: Why does C allow structs to have a tag?Bart
| |   |    |  `* Re: Why does C allow structs to have a tag?Bart
| |   |    |   +- Re: Why does C allow structs to have a tag?David Brown
| |   |    |   `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    +* Re: Why does C allow structs to have a tag?Guillaume
| |   |    |    |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |    ||`- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |    `* Re: Why does C allow structs to have a tag?Bart
| |   |    |     `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |      `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |`* Re: Why does C allow structs to have a tag?Ben Bacarisse
| |   |    |       | `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    | `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       |    `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       `- Re: Why does C allow structs to have a tag?David Brown
| |   |    `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |     `* Re: Why does C allow structs to have a tag?Bart
| |   |      `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |       `- Re: Why does C allow structs to have a tag?Bart
| |   `* Re: Why does C allow structs to have a tag?Bart
| |    +- Re: Why does C allow structs to have a tag?Keith Thompson
| |    `- Re: Why does C allow structs to have a tag?Kaz Kylheku
| +* Re: Why does C allow structs to have a tag?Joe Pfeiffer
| |`- Re: Why does C allow structs to have a tag?Kaz Kylheku
| `- Re: Why does C allow structs to have a tag?Richard Damon
+* Re: Why does C allow structs to have a tag?John Bode
+- Re: Why does C allow structs to have a tag?Siri Cruise
`* Re: Why does C allow structs to have a tag?Andrey Tarasevich

Pages:12345678910111213141516
Re: Why does C allow structs to have a tag?

<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17840&group=comp.lang.c#17840

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2101:: with SMTP id l1mr5037094qkl.104.1628461846811; Sun, 08 Aug 2021 15:30:46 -0700 (PDT)
X-Received: by 2002:a37:6393:: with SMTP id x141mr2658647qkb.287.1628461846677; Sun, 08 Aug 2021 15:30:46 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sun, 8 Aug 2021 15:30:46 -0700 (PDT)
In-Reply-To: <877dgvljpf.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=87.68.183.224; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 87.68.183.224
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me> <se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Sun, 08 Aug 2021 22:30:46 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 92
 by: Michael S - Sun, 8 Aug 2021 22:30 UTC

On Monday, August 9, 2021 at 12:17:59 AM UTC+3, Ben Bacarisse wrote:
> Bart <b...@freeuk.com> writes:
>
> > On 08/08/2021 20:21, Ben Bacarisse wrote:
> >> Bart <b...@freeuk.com> writes:
> >>
> >>>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
> >>>
> >>> You're right; this program:
> >>>
> >>> #include <stdio.h>
> >>> int main(void) {
> >>> for (int i=0; i<10000; ++i)
> >>> printf("%-16s","1234567890"); // no newlines
> >>> }
> >>>
> >>> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
> >>> never noticed before.
> >> You often post times with no indication of what's being measured.
> >
> > Huh? The test program is shown above. A tcc-compiled program takes 7
> > times as long as gcc- or clang-compiled one. On Windows (I know Linux
> > has super-fast console output).
> >
> > What I'm measuring is how long between starting the program, and
> > finishing writing stuff to the screen, because on Windows you can see
> > all this output scrolling up the screen.
> You've been in the business for many years. I can't believe you don't
> know what I mean.
> >> The
> >> compiler probably has little to do with it. What C library is being
> >> used? How is the output handled?
> >
> > I don't know, but... should anyone really have to delve into the exact
> > implementation of printf to get it to do its job properly? It should
> > just work! Which means not working a magnitude slower than it should.
> I my machine is three times faster than yours (just to get a simple
> number) we are talking about three orders of magnitude. Do you think
> that's down to the implementation of printf? You certainly haven't
> posted any data to support that.
> > See my other post a few minutes after yours for further investigations.
> >
> >>> You can try bypassing printf in gcc by using sprintf to a string for a
> >>> complete line of output, then using puts() on the string. However you
> >>> shouldn't need to do this.
> >> Why do you think the problem (whatever it is) has got anything to do
> >> with gcc if the problem disappears when the output is redirected?
> >
> > The 'problem' is with clang/gcc calling 'printf'. All compilers are
> > told to use printf, yet only these two compilers end up being slow.
> I thought you said the problem goes away when the output is redirected?
> gcc and clang don't generate code that does not call printf when the
> output is redirected.
> > But if that is the case, who's fault is that, and what can one do
> > about it? Do you think it is likely to involve messing with the
> > options for these gcc or clang installations?
> >
> > Because you seem keen to put the blame elsewhere.
> Because I think the blame must be elsewhere, but I'm not going to
> install Windows (and all the other stuff one might need) just to find
> out.

That, probably, wouldn't help.
Bart and DFS are unique people with unique capabilities.
DFS more so, but Bart's ability to hit roadbles that almost nobody else hit also shouldn't be underestimated.
Out of interest, I logged into machine where I have several cygwin installations
(all coming with various versions of Altera Nios II EDS suit) ranging from 2009 to 2018.
I compiles Bart's program and run it. I looked a bit slow, but not dramatically so.
I timed it with time. Depending on the version, time varied between 90 and 370 msec.
Yes, it's very slow (under MSYS2, on my significantly older and slower home desktop, it took 20ms,
of which, I'd guess, more than half is loading program rather than running it) but not *nearly* as slow
as reported by Bart and DFS.

But then I figured out how to make it *really* slow.
First, you should find *very* old cygwin. Of all my installations only one from 2009 is old enough.
Second, you should compile/link with flag '-mno-cygwin".
Third, you should run the executive in normal windows command window rather than in cygwing window.
Only then you will be able to see the slowness.
It seems, this particular combination of tools and environment dislikes very long lines.

It's still not guaranteed, that you'll see times, reported by Bart. It depends on many factors, most
importantly, on the exact size of your command window.
Personally, I had never seen more than 2.5 or 3 seconds.
But that difference , at least, can be explained by difference in speed between my hardware
(4-5 y.o. Haswell with 32GB of RAM and decent SSD) and the hardware used by Bart.

> > What can you tell DFS to make fix this problem when using gcc?
> To get 1000-fold increase in speed, ditch Windows. If he or she must
> use Windows, find out what's taking the time.
>
> --
> Ben.

Re: Why does C allow structs to have a tag?

<seppk7$amr$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17841&group=comp.lang.c#17841

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 00:33:25 +0100
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <seppk7$amr$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 8 Aug 2021 23:33:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="10971"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u5IjNV7mdzAcnROS1UGjj5ynEuSdD+iY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:rW+uLEJ9LwCmTAV6HX9gb0ggFHs=
In-Reply-To: <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210808-0, 8/8/2021), Outbound message
 by: Bart - Sun, 8 Aug 2021 23:33 UTC

On 08/08/2021 23:30, Michael S wrote:
> On Monday, August 9, 2021 at 12:17:59 AM UTC+3, Ben Bacarisse wrote:

>>>
>>> Because you seem keen to put the blame elsewhere.
>> Because I think the blame must be elsewhere, but I'm not going to
>> install Windows (and all the other stuff one might need) just to find
>> out.
>
> That, probably, wouldn't help.
> Bart and DFS are unique people with unique capabilities.
> DFS more so, but Bart's ability to hit roadbles that almost nobody else hit also shouldn't be underestimated.
> Out of interest, I logged into machine where I have several cygwin installations
> (all coming with various versions of Altera Nios II EDS suit) ranging from 2009 to 2018.
> I compiles Bart's program and run it. I looked a bit slow, but not dramatically so.
> I timed it with time. Depending on the version, time varied between 90 and 370 msec.
> Yes, it's very slow (under MSYS2, on my significantly older and slower home desktop, it took 20ms,
> of which, I'd guess, more than half is loading program rather than running it) but not *nearly* as slow
> as reported by Bart and DFS.
>
> But then I figured out how to make it *really* slow.
> First, you should find *very* old cygwin. Of all my installations only one from 2009 is old enough.
> Second, you should compile/link with flag '-mno-cygwin".

Cygwin and MSYS2? I'm talking about plain Windows. I've no idea what's
going on in those products; maybe they use different console programs or
different C runtimes from those used from plain Windows.

Third, you should run the executive in normal windows command window
rather than in cygwing window.
> Only then you will be able to see the slowness.
> It seems, this particular combination of tools and environment dislikes very long lines.
>
> It's still not guaranteed, that you'll see times, reported by Bart. It depends on many factors, most
> importantly, on the exact size of your command window.
> Personally, I had never seen more than 2.5 or 3 seconds.
> But that difference , at least, can be explained by difference in speed between my hardware
> (4-5 y.o. Haswell with 32GB of RAM and decent SSD) and the hardware used by Bart.

Try these two versions:

#include <stdio.h>

int main(void) {
for (int i=0; i<2000; ++i) {
printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n");
}
}

--------------------------------------------

#include <stdio.h>

int main(void) {
for (int i=0; i<2000; ++i) {
for (int j=0; j<79; ++j) printf("X");
puts("");
}
}

The first generally runs in 1.7 seconds (display is 60 rows of 100
chars), the second in 25-26 seconds, using bcc/tcc/DMC/CL compilers.

But with gcc/clang, both run in 25-26 seconds (lccwin took 20 seconds)

What's going on in those latter compilers? You tell me.

My idea was that gcc ends up calling fprintf a character at a time, or
maybe fputc (it doesn't import printf).

BTW I don't appreciate your getting personal. I'm only reporting what
I've actually observed.

Remarks along the lines of 'Ah, well Windows is dead slow anyway, what
difference does another magnitude slow make' are not helpful.

Re: Why does C allow structs to have a tag?

<Wg_PI.6656$NQ1.5159@fx48.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17842&group=comp.lang.c#17842

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!feeder1.feed.usenet.farm!feed.usenet.farm!peer01.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx48.iad.POSTED!not-for-mail
From: nos...@dfs.com (DFS)
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 103
Message-ID: <Wg_PI.6656$NQ1.5159@fx48.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Mon, 09 Aug 2021 00:03:02 UTC
Organization: blocknews - www.blocknews.net
Date: Sun, 8 Aug 2021 20:03:01 -0400
X-Received-Bytes: 5017
 by: DFS - Mon, 9 Aug 2021 00:03 UTC

On 8/8/2021 6:30 PM, Michael S wrote:

> Bart and DFS are unique people with unique capabilities. DFS more so,

What are you babbling about?

> but Bart's ability to hit roadbles that almost nobody else hit also
> shouldn't be underestimated.

There's no reason for anyone to get different results that what Bart and
I experienced.

Running Win10 21H1. Wanted a better compiler than tcc (0.9.27), so I
installed the gcc from:

https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z
(gcc 11.2.0)

$gcc -Wall source.c -o prog.exe

created a huge executable that ran printf() very slowly.

Tried another one:

https://github.com/skeeto/w64devkit/releases/tag/v1.8.0 (gcc 11.1.0)

also created a huge executable that ran printf() very slowly.

gcc Windows: slow 3.15s
tcc Windows: quick 0.24s
gcc Linux : incredibly quick (like 0.01, no time to blink)

And that's just 726 words.

Code is standard printf() stuff I think:

//get max number of columns to print on each line
//tcols = number of columns on terminal screen
//add 2 to longword to account for spaces

int maxcols = ((int)(tcols/(longword+2)));
int cols=1;
for(int i=0;i<matchcnt;i++)
{ printf("%-*s ", longword, matchwords[i]);
cols++;
if(cols>maxcols) {
printf("\n");
cols=1;
}
}

Remove the column breaks and it's just as slow.

> Out of interest, I logged into machine where I have several cygwin
> installations (all coming with various versions of Altera Nios II EDS
> suit) ranging from 2009 to 2018. I compiles Bart's program and run
> it. I looked a bit slow, but not dramatically so. I timed it with
> time. Depending on the version, time varied between 90 and 370 msec.
> Yes, it's very slow (under MSYS2, on my significantly older and
> slower home desktop, it took 20ms, of which, I'd guess, more than
> half is loading program rather than running it) but not *nearly* as
> slow as reported by Bart and DFS.
>
> But then I figured out how to make it *really* slow. First, you
> should find *very* old cygwin. Of all my installations only one from
> 2009 is old enough. Second, you should compile/link with flag
> '-mno-cygwin". Third, you should run the executive in normal windows
> command window rather than in cygwing window. Only then you will be
> able to see the slowness. It seems, this particular combination of
> tools and environment dislikes very long lines.
>
> It's still not guaranteed, that you'll see times, reported by Bart.
> It depends on many factors, most importantly, on the exact size of
> your command window.

My code polls the size of the terminal window before printing, to
determine how many columns of the widest word in the result set will fit
cleanly. Whether the window is wide (10 columns) or narrow (5
columns), the gcc Windows printf() is about the same: just over 3
seconds to print 726 words.

I think Kaz Kylheku nailed it: difference in printf() implementation
between tcc and gcc.

> Personally, I had never seen more than 2.5 or 3
> seconds. But that difference , at least, can be explained by
> difference in speed between my hardware (4-5 y.o. Haswell with 32GB
> of RAM and decent SSD) and the hardware used by Bart.

I run an 11-year-old chip: i5-750@2.67GHz, 8GB mem, Mushkin Reactor SSD.

Re: Why does C allow structs to have a tag?

<871r73la1b.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17843&group=comp.lang.c#17843

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 09 Aug 2021 01:46:40 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <871r73la1b.fsf@bsb.me.uk>
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="196fca43467c90615119474f2257b729";
logging-data="8086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+BON7zTZcwncS+7Bgf6OP+tlkv3EjyXOA="
Cancel-Lock: sha1:ltMTB2YwcxRQzRZyc3Lm/p00hts=
sha1:5IAOS3OIDcE6M8kCfPrKVk/IwDo=
X-BSB-Auth: 1.11cf0616913ae3597d92.20210809014640BST.871r73la1b.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 9 Aug 2021 00:46 UTC

Bart <bc@freeuk.com> writes:

> On 08/08/2021 22:17, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>
>>> The 'problem' is with clang/gcc calling 'printf'. All compilers are
>>> told to use printf, yet only these two compilers end up being slow.
>> I thought you said the problem goes away when the output is redirected?
>> gcc and clang don't generate code that does not call printf when the
>> output is redirected.
>
> I thought I explained what might have been happening: gcc might end up
> calling a routine in msvcrt that works a character at a time, rather
> than a string at a time. And the former might be slower when sent to
> the console so you don't see a problem with file output.

gcc is a compiler. It generates code that calls printf or similar.
After that, what happens is nothing to do with gcc.

>>> What can you tell DFS to make fix this problem when using gcc?
>> To get 1000-fold increase in speed, ditch Windows. If he or she must
>> use Windows, find out what's taking the time.
>
> Where did the 1000-fold increase come from? The slowdown on my last
> test was about 14 times, in line with what DFS reported.

You reported 21s, I measured 0.007s, both using gcc. The difference is
almost certainly be due to implementation components other than gcc.

--
Ben.

Re: Why does C allow structs to have a tag?

<slrnsh1g90.c0p.ike@rie.sdf.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17844&group=comp.lang.c#17844

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ike...@rie.sdf.org (Ike Naar)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 05:46:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <slrnsh1g90.c0p.ike@rie.sdf.org>
References: <s9iea5$n5c$1@dont-email.me>
<87a6m5f0j9.fsf@nosuchdomain.example.com> <sdusob$h8b$1@dont-email.me>
<20210730075628.870@kylheku.com> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me>
Injection-Date: Mon, 9 Aug 2021 05:46:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1a67082bab42fcd6a42b73e6312a815e";
logging-data="5819"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uDxSc2PXy3rs+Y+F2SOvg"
User-Agent: slrn/1.0.3 (Patched for libcanlock3) (NetBSD)
Cancel-Lock: sha1:JlJV13Tu9x1tnNtx/cK5miZEkwE=
 by: Ike Naar - Mon, 9 Aug 2021 05:46 UTC

On 2021-08-08, Bart <bc@freeuk.com> wrote:
> On 08/08/2021 13:51, DFS wrote:
>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
>
> You're right; this program:
>
> #include <stdio.h>
> int main(void) {
> for (int i=0; i<10000; ++i)
> printf("%-16s","1234567890"); // no newlines
> }
>
> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
> never noticed before.
>
> My bcc compiler, which also calls printf in msvcrt, does it in 2.3
> seconds for some reason. lccwin is 15 seconds, DM 2.7. MSVC is 2.7 too.
> Clang is 21 seconds (which is taking being a gcc clone to extremes).
>
> All very strange. I don't know how much this is important, or how much
> text you're printing to the screen, since 500 printfs per second is
> still faster than anyone can read it. The problem disappears if you
> redirect to a file.

It might depend on whether the output stream is buffered or not.
I'd expect output to the console to be unbuffered.
What happens if you change it to fully buffered, adding

setvbuf(stdout, NULL, _IOFBF, 0);

at the start of the program?

Re: Why does C allow structs to have a tag?

<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17845&group=comp.lang.c#17845

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:cac:: with SMTP id s12mr11443459qvs.28.1628497769846;
Mon, 09 Aug 2021 01:29:29 -0700 (PDT)
X-Received: by 2002:a05:620a:1506:: with SMTP id i6mr21688154qkk.199.1628497769693;
Mon, 09 Aug 2021 01:29:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 01:29:29 -0700 (PDT)
In-Reply-To: <Wg_PI.6656$NQ1.5159@fx48.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me>
<se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com> <Wg_PI.6656$NQ1.5159@fx48.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 08:29:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 9 Aug 2021 08:29 UTC

On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
> On 8/8/2021 6:30 PM, Michael S wrote:
>
> > Bart and DFS are unique people with unique capabilities. DFS more so,
> What are you babbling about?

Your shared love to strange tools that wouldn't in top#5 list of choice of professional and likely not in top#10.

> > but Bart's ability to hit roadbles that almost nobody else hit also
> > shouldn't be underestimated.
> There's no reason for anyone to get different results that what Bart and
> I experienced.
>
> Running Win10 21H1. Wanted a better compiler than tcc (0.9.27), so I
> installed the gcc from:
>
> https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z
> (gcc 11.2.0)

That loooks like mingw-64. The same compiler/libraries that I tried first and that finished the task in 20 msec - 1000 times faster than you (or Bart) reported.

AFAIK, it's C RTL is based on Microsoft's DLL that was originally distributed with VS2013.
Recently, they (MSYS2 maintainers) added a variant of library that is called ucrt-something,
probably based on more up to date Microsoft's DLL. I didn't try it yet.

I didn't see the slowness because I was running it from msys2 command window, i.e. the same environment in which that it was tested by maintainers.
When I take generated exe file and try to run it in regular windows command window (cmd.exe)
or in powershell window then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec in powereshell.
When I changed the size of cmd window to "traditional" defaults of 80x25, it slowed down to 6 seconds.

>
> $gcc -Wall source.c -o prog.exe
>
> created a huge executable that ran printf() very slowly.
>

Huge executive is due to presence of symbols. gcc -s (symbols stripped) is just big, not huge.

Slowness is due to interaction between startup code in mingw64 library and windows command prompt environment,
probably not provisioned by maintainers since they expect their console programs to be run under msys2.

As said by several people here, under such combo stdout behaves as unbuffered. So, 160,000 system calls.
By themselves, 160,000 system calls are not particularly slow, but Windows console subsystem seems obliged
to redraw the whole window each time the character does not fit in window width.
Or, may be, even more often, may be, once per character.
So far I didn't figure out how to find exact details.

>
> Tried another one:
>
> https://github.com/skeeto/w64devkit/releases/tag/v1.8.0 (gcc 11.1.0)
>

If you want to use msys2-maintained gcc compiler then I strongly recommend
to stick to "official" msys2 distribution.
https://www.msys2.org/

> also created a huge executable that ran printf() very slowly.
>
> gcc Windows: slow 3.15s
> tcc Windows: quick 0.24s
> gcc Linux : incredibly quick (like 0.01, no time to blink)
>

0.01 I'd call o.k. rather than "incredibly quick"

> And that's just 726 words.
>
>
>
> Code is standard printf() stuff I think:
>
> //get max number of columns to print on each line
> //tcols = number of columns on terminal screen
> //add 2 to longword to account for spaces
>
> int maxcols = ((int)(tcols/(longword+2)));
> int cols=1;
> for(int i=0;i<matchcnt;i++)
> {
> printf("%-*s ", longword, matchwords[i]);
> cols++;
> if(cols>maxcols) {
> printf("\n");
> cols=1;
> }
> }
>
> Remove the column breaks and it's just as slow.
> > Out of interest, I logged into machine where I have several cygwin
> > installations (all coming with various versions of Altera Nios II EDS
> > suit) ranging from 2009 to 2018. I compiles Bart's program and run
> > it. I looked a bit slow, but not dramatically so. I timed it with
> > time. Depending on the version, time varied between 90 and 370 msec.
> > Yes, it's very slow (under MSYS2, on my significantly older and
> > slower home desktop, it took 20ms, of which, I'd guess, more than
> > half is loading program rather than running it) but not *nearly* as
> > slow as reported by Bart and DFS.
> >
> > But then I figured out how to make it *really* slow. First, you
> > should find *very* old cygwin. Of all my installations only one from
> > 2009 is old enough. Second, you should compile/link with flag
> > '-mno-cygwin". Third, you should run the executive in normal windows
> > command window rather than in cygwing window. Only then you will be
> > able to see the slowness. It seems, this particular combination of
> > tools and environment dislikes very long lines.
> >
> > It's still not guaranteed, that you'll see times, reported by Bart.
> > It depends on many factors, most importantly, on the exact size of
> > your command window.
> My code polls the size of the terminal window before printing, to
> determine how many columns of the widest word in the result set will fit
> cleanly. Whether the window is wide (10 columns) or narrow (5
> columns), the gcc Windows printf() is about the same: just over 3
> seconds to print 726 words.
>
> I think Kaz Kylheku nailed it: difference in printf() implementation
> between tcc and gcc.
> > Personally, I had never seen more than 2.5 or 3
> > seconds. But that difference , at least, can be explained by
> > difference in speed between my hardware (4-5 y.o. Haswell with 32GB
> > of RAM and decent SSD) and the hardware used by Bart.
> I run an 11-year-old chip: i5-...@2.67GHz, 8GB mem, Mushkin Reactor SSD.

As written above, now I found a way (on somewhat slower HW then the one used originally) to increase the time to 6 seconds.

Re: Why does C allow structs to have a tag?

<45070459-0768-4e68-8ea7-0f115c2180e4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17846&group=comp.lang.c#17846

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:e102:: with SMTP id g2mr22296467qkm.70.1628498317911;
Mon, 09 Aug 2021 01:38:37 -0700 (PDT)
X-Received: by 2002:a37:e46:: with SMTP id 67mr22615071qko.7.1628498317782;
Mon, 09 Aug 2021 01:38:37 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 01:38:37 -0700 (PDT)
In-Reply-To: <slrnsh1g90.c0p.ike@rie.sdf.org>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
<sdusob$h8b$1@dont-email.me> <20210730075628.870@kylheku.com>
<se160r$o5c$1@dont-email.me> <se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <slrnsh1g90.c0p.ike@rie.sdf.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <45070459-0768-4e68-8ea7-0f115c2180e4n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 08:38:37 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 9 Aug 2021 08:38 UTC

On Monday, August 9, 2021 at 8:46:20 AM UTC+3, Ike Naar wrote:
> On 2021-08-08, Bart <b...@freeuk.com> wrote:
> > On 08/08/2021 13:51, DFS wrote:
> >> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
> >
> > You're right; this program:
> >
> > #include <stdio.h>
> > int main(void) {
> > for (int i=0; i<10000; ++i)
> > printf("%-16s","1234567890"); // no newlines
> > }
> >
> > runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
> > never noticed before.
> >
> > My bcc compiler, which also calls printf in msvcrt, does it in 2.3
> > seconds for some reason. lccwin is 15 seconds, DM 2.7. MSVC is 2.7 too.
> > Clang is 21 seconds (which is taking being a gcc clone to extremes).
> >
> > All very strange. I don't know how much this is important, or how much
> > text you're printing to the screen, since 500 printfs per second is
> > still faster than anyone can read it. The problem disappears if you
> > redirect to a file.
> It might depend on whether the output stream is buffered or not.
> I'd expect output to the console to be unbuffered.
> What happens if you change it to fully buffered, adding
>
> setvbuf(stdout, NULL, _IOFBF, 0);
>
> at the start of the program?

Such addition changes nothing.
But setvbuf(stdout, NULL, _IOFBF, 512); cuts the run time from 6 sec down to 170-300 msec.

Re: Why does C allow structs to have a tag?

<e9378781-ac20-434a-84cc-e6a4c3f26953n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17847&group=comp.lang.c#17847

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:e109:: with SMTP id g9mr22558983qkm.95.1628499446782;
Mon, 09 Aug 2021 01:57:26 -0700 (PDT)
X-Received: by 2002:a05:6214:e4e:: with SMTP id o14mr11382646qvc.55.1628499446659;
Mon, 09 Aug 2021 01:57:26 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 01:57:26 -0700 (PDT)
In-Reply-To: <45070459-0768-4e68-8ea7-0f115c2180e4n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <87a6m5f0j9.fsf@nosuchdomain.example.com>
<sdusob$h8b$1@dont-email.me> <20210730075628.870@kylheku.com>
<se160r$o5c$1@dont-email.me> <se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <slrnsh1g90.c0p.ike@rie.sdf.org>
<45070459-0768-4e68-8ea7-0f115c2180e4n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e9378781-ac20-434a-84cc-e6a4c3f26953n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 08:57:26 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 9 Aug 2021 08:57 UTC

On Monday, August 9, 2021 at 11:38:43 AM UTC+3, Michael S wrote:
> On Monday, August 9, 2021 at 8:46:20 AM UTC+3, Ike Naar wrote:
> > On 2021-08-08, Bart <b...@freeuk.com> wrote:
> > > On 08/08/2021 13:51, DFS wrote:
> > >> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
> > >
> > > You're right; this program:
> > >
> > > #include <stdio.h>
> > > int main(void) {
> > > for (int i=0; i<10000; ++i)
> > > printf("%-16s","1234567890"); // no newlines
> > > }
> > >
> > > runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
> > > never noticed before.
> > >
> > > My bcc compiler, which also calls printf in msvcrt, does it in 2.3
> > > seconds for some reason. lccwin is 15 seconds, DM 2.7. MSVC is 2.7 too.
> > > Clang is 21 seconds (which is taking being a gcc clone to extremes).
> > >
> > > All very strange. I don't know how much this is important, or how much
> > > text you're printing to the screen, since 500 printfs per second is
> > > still faster than anyone can read it. The problem disappears if you
> > > redirect to a file.
> > It might depend on whether the output stream is buffered or not.
> > I'd expect output to the console to be unbuffered.
> > What happens if you change it to fully buffered, adding
> >
> > setvbuf(stdout, NULL, _IOFBF, 0);
> >
> > at the start of the program?
> Such addition changes nothing.
> But setvbuf(stdout, NULL, _IOFBF, 512); cuts the run time from 6 sec down to 170-300 msec.

BTW, by setting setvbuf(stdout, NULL, _IONBF, 0); I was able to reproduce a "slow" behaviour with Microsoft's dev tools.

Re: Why does C allow structs to have a tag?

<sequ10$55f$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17848&group=comp.lang.c#17848

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 10:54:37 +0100
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <sequ10$55f$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 09:54:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="5295"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/GgMxLCScFGWX8uADBVT01F7CVL51Kymc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:UN9sI1CCgJZw+akm3FuEJJwz1Jc=
In-Reply-To: <871r73la1b.fsf@bsb.me.uk>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-0, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 09:54 UTC

On 09/08/2021 01:46, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 08/08/2021 22:17, Ben Bacarisse wrote:
>>> Bart <bc@freeuk.com> writes:
>>
>>>> The 'problem' is with clang/gcc calling 'printf'. All compilers are
>>>> told to use printf, yet only these two compilers end up being slow.
>>> I thought you said the problem goes away when the output is redirected?
>>> gcc and clang don't generate code that does not call printf when the
>>> output is redirected.
>>
>> I thought I explained what might have been happening: gcc might end up
>> calling a routine in msvcrt that works a character at a time, rather
>> than a string at a time. And the former might be slower when sent to
>> the console so you don't see a problem with file output.
>
> gcc is a compiler. It generates code that calls printf or similar.

Actually, it doesn't. As I said, it calls an inline version of printf in
its stdio.h, which ends up calling __mingw_vfprintf.

I /can/ get it to call the same printf I do, by using this declaration
in place of stdio.h:

extern int printf(const char*, ...);

The problem is that it - my gcc installation - does something different.

> After that, what happens is nothing to do with gcc.

You're still trying to play that card.

>>>> What can you tell DFS to make fix this problem when using gcc?
>>> To get 1000-fold increase in speed, ditch Windows. If he or she must
>>> use Windows, find out what's taking the time.
>>
>> Where did the 1000-fold increase come from? The slowdown on my last
>> test was about 14 times, in line with what DFS reported.
>

> You reported 21s, I measured 0.007s, both using gcc.

The upper limit of what can be achieved on my Windows system using i/o
via msvcrt.dll seems to be about 1.7 seconds for my test (2000
80-character strings, approx 100K chars per second.

It will slow down in every case if I write much shorter strings, or
single characters.

I can't do much about that. Yet some compilers - sorry compilers plus
whatever components they've been bundled with - exhibit that slowness
even with long strings.

> The difference is
> almost certainly be due to implementation components other than gcc.
>

Sure; I'm using a gcc 'bundle', as nearly everyone will be. But such
installations are huge; most people will have to trust whatever
components have been included.

> You reported 21s, I measured 0.007s, both using gcc.

I think that was test was 10000 16-character strings, with no newlines
so less impact of scrolling. 7ms means 23M characters per second on a
graphical, bit-mapped, scrolling character display.

(Or I assume it is graphical; if a text-mode display, then that's not
playing the game.)

At 23Mcps, I don't know what tricks the terminal driver is doing to
achieve that. Maybe it's writing into a virtual screen (a text-mode
buffer not bit-mapped), and only updating the display intermittently. Or
maybe its better at using whatever hardware acceleration exists.

The tricks could probably be done on Windows too (eg. using DirectDraw
or whatever). But probably not via the clunky console routines that MS
provides.

But that is all besides the point, which is this: gcc/clang
installations on plain Windows using a normal console window, do
something that makes printing via printf even slower than it already is.

Re: Why does C allow structs to have a tag?

<sequ22$55f$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17849&group=comp.lang.c#17849

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 10:55:12 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <sequ22$55f$2@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me>
<87a6m5f0j9.fsf@nosuchdomain.example.com> <sdusob$h8b$1@dont-email.me>
<20210730075628.870@kylheku.com> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <slrnsh1g90.c0p.ike@rie.sdf.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 09:55:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="5295"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+pJdwhlyQDeT5TOG576OaSft/YsG5EUzw="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:OvOsI430A7FwxPW1+k9mWnKA2Vg=
In-Reply-To: <slrnsh1g90.c0p.ike@rie.sdf.org>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-0, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 09:55 UTC

On 09/08/2021 06:46, Ike Naar wrote:
> On 2021-08-08, Bart <bc@freeuk.com> wrote:
>> On 08/08/2021 13:51, DFS wrote:
>>> The gcc-Windows compiled version does printf() at 1/4 the speed of tcc.
>>
>> You're right; this program:
>>
>> #include <stdio.h>
>> int main(void) {
>> for (int i=0; i<10000; ++i)
>> printf("%-16s","1234567890"); // no newlines
>> }
>>
>> runs in 3 seconds with tcc. With gcc, 21 seconds, even optimised. I've
>> never noticed before.
>>
>> My bcc compiler, which also calls printf in msvcrt, does it in 2.3
>> seconds for some reason. lccwin is 15 seconds, DM 2.7. MSVC is 2.7 too.
>> Clang is 21 seconds (which is taking being a gcc clone to extremes).
>>
>> All very strange. I don't know how much this is important, or how much
>> text you're printing to the screen, since 500 printfs per second is
>> still faster than anyone can read it. The problem disappears if you
>> redirect to a file.
>
> It might depend on whether the output stream is buffered or not.
> I'd expect output to the console to be unbuffered.
> What happens if you change it to fully buffered, adding
>
> setvbuf(stdout, NULL, _IOFBF, 0);
>
> at the start of the program?
>

No, only if I use 512 instead of 0 as posted elsewhere.

Re: Why does C allow structs to have a tag?

<1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17850&group=comp.lang.c#17850

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:2583:: with SMTP id fq3mr790555qvb.42.1628506785060; Mon, 09 Aug 2021 03:59:45 -0700 (PDT)
X-Received: by 2002:a05:620a:5f2:: with SMTP id z18mr14026238qkg.495.1628506784915; Mon, 09 Aug 2021 03:59:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 03:59:44 -0700 (PDT)
In-Reply-To: <sequ10$55f$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk> <sequ10$55f$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 10:59:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 99
 by: Michael S - Mon, 9 Aug 2021 10:59 UTC

On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:
> On 09/08/2021 01:46, Ben Bacarisse wrote:
> > Bart <b...@freeuk.com> writes:
> >
> >> On 08/08/2021 22:17, Ben Bacarisse wrote:
> >>> Bart <b...@freeuk.com> writes:
> >>
> >>>> The 'problem' is with clang/gcc calling 'printf'. All compilers are
> >>>> told to use printf, yet only these two compilers end up being slow.
> >>> I thought you said the problem goes away when the output is redirected?
> >>> gcc and clang don't generate code that does not call printf when the
> >>> output is redirected.
> >>
> >> I thought I explained what might have been happening: gcc might end up
> >> calling a routine in msvcrt that works a character at a time, rather
> >> than a string at a time. And the former might be slower when sent to
> >> the console so you don't see a problem with file output.
> >
> > gcc is a compiler. It generates code that calls printf or similar.
> Actually, it doesn't. As I said, it calls an inline version of printf in
> its stdio.h, which ends up calling __mingw_vfprintf.
>
> I /can/ get it to call the same printf I do, by using this declaration
> in place of stdio.h:
> extern int printf(const char*, ...);
> The problem is that it - my gcc installation - does something different.
> > After that, what happens is nothing to do with gcc.
> You're still trying to play that card.
> >>>> What can you tell DFS to make fix this problem when using gcc?
> >>> To get 1000-fold increase in speed, ditch Windows. If he or she must
> >>> use Windows, find out what's taking the time.
> >>
> >> Where did the 1000-fold increase come from? The slowdown on my last
> >> test was about 14 times, in line with what DFS reported.
> >
>
> > You reported 21s, I measured 0.007s, both using gcc.
> The upper limit of what can be achieved on my Windows system using i/o
> via msvcrt.dll seems to be about 1.7 seconds for my test (2000
> 80-character strings, approx 100K chars per second.
>
> It will slow down in every case if I write much shorter strings, or
> single characters.
>
> I can't do much about that. Yet some compilers - sorry compilers plus
> whatever components they've been bundled with - exhibit that slowness
> even with long strings.
> > The difference is
> > almost certainly be due to implementation components other than gcc.
> >
> Sure; I'm using a gcc 'bundle', as nearly everyone will be. But such
> installations are huge; most people will have to trust whatever
> components have been included.
> > You reported 21s, I measured 0.007s, both using gcc.
> I think that was test was 10000 16-character strings, with no newlines
> so less impact of scrolling. 7ms means 23M characters per second on a
> graphical, bit-mapped, scrolling character display.
>
> (Or I assume it is graphical; if a text-mode display, then that's not
> playing the game.)
>
> At 23Mcps, I don't know what tricks the terminal driver is doing to
> achieve that. Maybe it's writing into a virtual screen (a text-mode
> buffer not bit-mapped), and only updating the display intermittently. Or
> maybe its better at using whatever hardware acceleration exists.
>

I'd guess, it's much simpler.
A Linux terminal maintains a big queue, which, in absence of special commands from the user,
is polled by rendering thread on consumer end 50 or 60 times per second.
You can see a very similar behavior if you run your "slow" exe from terminal (mintty.exe), supplied with msys2.

I'd guess, something similar can be achieved with cmd.exe console by using non-default console output mode
(see SetConsoleMode()) but I never tried it.

In my practice, I typically *want* printf output to be seen on screen ASAP and don't care in a slightest about achieved throughput. So, I strongly prefer "slow" defaults of cmd.exe and quite often find myself fighting against "fast" defaults of mintty by insertion of fflush().

> The tricks could probably be done on Windows too (eg. using DirectDraw
> or whatever). But probably not via the clunky console routines that MS
> provides.
>
> But that is all besides the point, which is this: gcc/clang
> installations on plain Windows using a normal console window, do
> something that makes printing via printf even slower than it already is.

Re: Why does C allow structs to have a tag?

<ser8jf$cd2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17851&group=comp.lang.c#17851

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 13:55:07 +0100
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <ser8jf$cd2$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
<sequ10$55f$1@dont-email.me>
<1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 12:55:11 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="12706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/PP0+lidrZjQYCIgO6xK8Ifb34uw+JHXI="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:0Ix59Upz1aB7dTmGwV7FdaRL36s=
In-Reply-To: <1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-0, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 12:55 UTC

On 09/08/2021 11:59, Michael S wrote:
> On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:

>> At 23Mcps, I don't know what tricks the terminal driver is doing to
>> achieve that. Maybe it's writing into a virtual screen (a text-mode
>> buffer not bit-mapped), and only updating the display intermittently. Or
>> maybe its better at using whatever hardware acceleration exists.
>>
>
> I'd guess, it's much simpler.
> A Linux terminal maintains a big queue, which, in absence of special commands from the user,
> is polled by rendering thread on consumer end 50 or 60 times per second.
> You can see a very similar behavior if you run your "slow" exe from terminal (mintty.exe), supplied with msys2.
>
> I'd guess, something similar can be achieved with cmd.exe console by using non-default console output mode
> (see SetConsoleMode()) but I never tried it.

Let's take this program:

#include <stdio.h>

int main(void) {
for (int i=0; i<1000000; ++i) {
printf("%d\n",i);
}
}

On Windows, using normal-speed printf, it takes 88 seconds to print
those 1 million numbers (about 80Kcps). But all of them get displayed.
(The binary to text conversion, tested using sprintf, is 0.4 seconds of
that.)

How long does the program take on a normal Linux system? Does each of
those one million numbers get displayed? Or is it only the last
screenful at the time that polling for display update gets done.

If not showing every number, and doing one million scroll operations,
then I'd consider that cheating, and would render timings such as 7ms
meaningless.

(My program run with gcc and without setvbuf or other workarounds took 8
minutes, or about 10Kcps, 8 times as slow as it could have been.

This 8x accords with there being about 8 characters output per printf
call, which include crlf (a detail which would make it marginally slower
than Linux anyway).)

Re: Why does C allow structs to have a tag?

<serct0$c90$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17852&group=comp.lang.c#17852

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 16:08:31 +0200
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <serct0$c90$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
<sequ10$55f$1@dont-email.me>
<1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
<ser8jf$cd2$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 9 Aug 2021 14:08:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e24b8315bbe4a39004204e3e6a251ded";
logging-data="12576"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wKOBVphCmqeGzmtf8Qbb4cMVAok3n878="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:F2dVvV/GQz1pjngbx4b0GG8KvS4=
In-Reply-To: <ser8jf$cd2$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Mon, 9 Aug 2021 14:08 UTC

On 09/08/2021 14:55, Bart wrote:
> On 09/08/2021 11:59, Michael S wrote:
>> On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:
>
>>> At 23Mcps, I don't know what tricks the terminal driver is doing to
>>> achieve that. Maybe it's writing into a virtual screen (a text-mode
>>> buffer not bit-mapped), and only updating the display intermittently. Or
>>> maybe its better at using whatever hardware acceleration exists.
>>>
>>
>> I'd guess, it's much simpler.
>> A Linux terminal maintains a big  queue, which, in absence of special
>> commands from the user,
>> is polled by rendering thread on consumer end 50 or 60 times per second.
>> You can see a very similar behavior if you run your "slow" exe from
>> terminal (mintty.exe), supplied with msys2.
>>
>> I'd guess, something similar can be achieved with cmd.exe console by
>> using non-default console output mode
>> (see SetConsoleMode()) but I never tried it.
>
> Let's take this program:
>
> #include <stdio.h>
>
> int main(void) {
>     for (int i=0; i<1000000; ++i) {
>         printf("%d\n",i);
>     }
> }
>
>
> On Windows, using normal-speed printf, it takes 88 seconds to print
> those 1 million numbers (about 80Kcps). But all of them get displayed.
> (The binary to text conversion, tested using sprintf, is 0.4 seconds of
> that.)
>
> How long does the program take on a normal Linux system? Does each of
> those one million numbers get displayed? Or is it only the last
> screenful at the time that polling for display update gets done.
>
> If not showing every number, and doing one million scroll operations,
> then I'd consider that cheating, and would render timings such as 7ms
> meaningless.
>
> (My program run with gcc and without setvbuf or other workarounds took 8
> minutes, or about 10Kcps, 8 times as slow as it could have been.
>
> This 8x accords with there being about 8 characters output per printf
> call, which include crlf (a detail which would make it marginally slower
> than Linux anyway).)
>

I've been mostly staying out of this conversation - I don't have a
Windows system available for any testing. However, I /can/ do some
timings on Linux.

Testing in a terminal window on my desktop (Linux Mint with Mate, so
approximately Gnome 2), it took 2.1 seconds. All million numbers are
there, and I can scroll back through the window buffer to see them.
Running it multiple times did not affect the timing, though the buffer
for the terminal gets bigger as it still holds all the lines. (This is
not typical behaviour on Windows command-prompt windows.)

Running on a Linux virtual console outside of X, it took 117 seconds on
the same system.

Running within a "screen" environment, with a default 1000 line history,
it was 1.85 seconds - it seems likely that the shorter buffer made it
more efficient.

None of that was using any special settings or commands - it's just the
program you gave, compiled with gcc 9 out of the box, no flags.

Piping the output into a file (6.6 million characters), to test the
speed without rendering the text, was about 0.09 seconds.

Timing for "cat" on this file, in a terminal window, was about 1 second.
So was the time taken to run "time ./test | cat".

Make of all that what you will.

Re: Why does C allow structs to have a tag?

<8d16684f-d1da-436e-8778-07e2adf99404n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17853&group=comp.lang.c#17853

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:15ad:: with SMTP id f13mr10781258qkk.0.1628520834915; Mon, 09 Aug 2021 07:53:54 -0700 (PDT)
X-Received: by 2002:ac8:ec4:: with SMTP id w4mr19198685qti.30.1628520834753; Mon, 09 Aug 2021 07:53:54 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!tr1.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 07:53:54 -0700 (PDT)
In-Reply-To: <serct0$c90$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:6c14:9c94:7aaa:3134; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:6c14:9c94:7aaa:3134
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me> <se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk> <sequ10$55f$1@dont-email.me> <1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com> <ser8jf$cd2$1@dont-email.me> <serct0$c90$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <8d16684f-d1da-436e-8778-07e2adf99404n@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Mon, 09 Aug 2021 14:53:54 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 87
 by: Malcolm McLean - Mon, 9 Aug 2021 14:53 UTC

On Monday, 9 August 2021 at 15:08:44 UTC+1, David Brown wrote:
> On 09/08/2021 14:55, Bart wrote:
> > On 09/08/2021 11:59, Michael S wrote:
> >> On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:
> >
> >>> At 23Mcps, I don't know what tricks the terminal driver is doing to
> >>> achieve that. Maybe it's writing into a virtual screen (a text-mode
> >>> buffer not bit-mapped), and only updating the display intermittently. Or
> >>> maybe its better at using whatever hardware acceleration exists.
> >>>
> >>
> >> I'd guess, it's much simpler.
> >> A Linux terminal maintains a big queue, which, in absence of special
> >> commands from the user,
> >> is polled by rendering thread on consumer end 50 or 60 times per second.
> >> You can see a very similar behavior if you run your "slow" exe from
> >> terminal (mintty.exe), supplied with msys2.
> >>
> >> I'd guess, something similar can be achieved with cmd.exe console by
> >> using non-default console output mode
> >> (see SetConsoleMode()) but I never tried it.
> >
> > Let's take this program:
> >
> > #include <stdio.h>
> >
> > int main(void) {
> > for (int i=0; i<1000000; ++i) {
> > printf("%d\n",i);
> > }
> > }
> >
> >
> > On Windows, using normal-speed printf, it takes 88 seconds to print
> > those 1 million numbers (about 80Kcps). But all of them get displayed.
> > (The binary to text conversion, tested using sprintf, is 0.4 seconds of
> > that.)
> >
> > How long does the program take on a normal Linux system? Does each of
> > those one million numbers get displayed? Or is it only the last
> > screenful at the time that polling for display update gets done.
> >
> > If not showing every number, and doing one million scroll operations,
> > then I'd consider that cheating, and would render timings such as 7ms
> > meaningless.
> >
> > (My program run with gcc and without setvbuf or other workarounds took 8
> > minutes, or about 10Kcps, 8 times as slow as it could have been.
> >
> > This 8x accords with there being about 8 characters output per printf
> > call, which include crlf (a detail which would make it marginally slower
> > than Linux anyway).)
> >
> I've been mostly staying out of this conversation - I don't have a
> Windows system available for any testing. However, I /can/ do some
> timings on Linux.
>
> Testing in a terminal window on my desktop (Linux Mint with Mate, so
> approximately Gnome 2), it took 2.1 seconds. All million numbers are
> there, and I can scroll back through the window buffer to see them.
> Running it multiple times did not affect the timing, though the buffer
> for the terminal gets bigger as it still holds all the lines. (This is
> not typical behaviour on Windows command-prompt windows.)
>
> Running on a Linux virtual console outside of X, it took 117 seconds on
> the same system.
>
> Running within a "screen" environment, with a default 1000 line history,
> it was 1.85 seconds - it seems likely that the shorter buffer made it
> more efficient.
>
> None of that was using any special settings or commands - it's just the
> program you gave, compiled with gcc 9 out of the box, no flags.
>
> Piping the output into a file (6.6 million characters), to test the
> speed without rendering the text, was about 0.09 seconds.
>
> Timing for "cat" on this file, in a terminal window, was about 1 second.
> So was the time taken to run "time ./test | cat".
>
> Make of all that what you will.
>
On a modern desktop system, parsing a printf format string, applying the
arguments, and creating a sequence of characters to pass to stdout doesn't
take much time. It's what happens after that stage that accounts for the
dufferences, which can be a factor of hundreds of thousands. Scrolling
a bit-mapped display on the CPU on every line write is going to be much
much slower than discarding the characters.

Re: Why does C allow structs to have a tag?

<16c39c11-53c7-46bc-9a0a-dfd8684a52can@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17854&group=comp.lang.c#17854

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:104c:: with SMTP id f12mr6630399qte.339.1628522343927;
Mon, 09 Aug 2021 08:19:03 -0700 (PDT)
X-Received: by 2002:a0c:ffae:: with SMTP id d14mr6705137qvv.41.1628522343819;
Mon, 09 Aug 2021 08:19:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 08:19:03 -0700 (PDT)
In-Reply-To: <serct0$c90$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <sepii6$k2g$1@dont-email.me>
<871r73la1b.fsf@bsb.me.uk> <sequ10$55f$1@dont-email.me> <1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
<ser8jf$cd2$1@dont-email.me> <serct0$c90$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <16c39c11-53c7-46bc-9a0a-dfd8684a52can@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 15:19:03 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 9 Aug 2021 15:19 UTC

On Monday, August 9, 2021 at 5:08:44 PM UTC+3, David Brown wrote:
> On 09/08/2021 14:55, Bart wrote:
> > On 09/08/2021 11:59, Michael S wrote:
> >> On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:
> >
> >>> At 23Mcps, I don't know what tricks the terminal driver is doing to
> >>> achieve that. Maybe it's writing into a virtual screen (a text-mode
> >>> buffer not bit-mapped), and only updating the display intermittently. Or
> >>> maybe its better at using whatever hardware acceleration exists.
> >>>
> >>
> >> I'd guess, it's much simpler.
> >> A Linux terminal maintains a big queue, which, in absence of special
> >> commands from the user,
> >> is polled by rendering thread on consumer end 50 or 60 times per second.
> >> You can see a very similar behavior if you run your "slow" exe from
> >> terminal (mintty.exe), supplied with msys2.
> >>
> >> I'd guess, something similar can be achieved with cmd.exe console by
> >> using non-default console output mode
> >> (see SetConsoleMode()) but I never tried it.
> >
> > Let's take this program:
> >
> > #include <stdio.h>
> >
> > int main(void) {
> > for (int i=0; i<1000000; ++i) {
> > printf("%d\n",i);
> > }
> > }
> >
> >
> > On Windows, using normal-speed printf, it takes 88 seconds to print
> > those 1 million numbers (about 80Kcps). But all of them get displayed.
> > (The binary to text conversion, tested using sprintf, is 0.4 seconds of
> > that.)
> >
> > How long does the program take on a normal Linux system? Does each of
> > those one million numbers get displayed? Or is it only the last
> > screenful at the time that polling for display update gets done.
> >
> > If not showing every number, and doing one million scroll operations,
> > then I'd consider that cheating, and would render timings such as 7ms
> > meaningless.
> >
> > (My program run with gcc and without setvbuf or other workarounds took 8
> > minutes, or about 10Kcps, 8 times as slow as it could have been.
> >
> > This 8x accords with there being about 8 characters output per printf
> > call, which include crlf (a detail which would make it marginally slower
> > than Linux anyway).)
> >
> I've been mostly staying out of this conversation - I don't have a
> Windows system available for any testing. However, I /can/ do some
> timings on Linux.
>
> Testing in a terminal window on my desktop (Linux Mint with Mate, so
> approximately Gnome 2), it took 2.1 seconds. All million numbers are
> there, and I can scroll back through the window buffer to see them.

Yes, they are there, in the buffer. But absolute majority of them they quite certainly never were seen on display.
It's just physically impossible, considering that display's vertical refresh
rate is measured in dozens per second.

> Running it multiple times did not affect the timing, though the buffer
> for the terminal gets bigger as it still holds all the lines. (This is
> not typical behaviour on Windows command-prompt windows.)
>

Much worse than "not typical".
For both cmd.exe and powershell not just an "out-of-the-box" default is very short (although less short for powershell), but configurable maximum is also short - 9999 lines.

> Running on a Linux virtual console outside of X, it took 117 seconds on
> the same system.
>
> Running within a "screen" environment, with a default 1000 line history,
> it was 1.85 seconds - it seems likely that the shorter buffer made it
> more efficient.
>
> None of that was using any special settings or commands - it's just the
> program you gave, compiled with gcc 9 out of the box, no flags.
>
> Piping the output into a file (6.6 million characters), to test the
> speed without rendering the text, was about 0.09 seconds.
>
> Timing for "cat" on this file, in a terminal window, was about 1 second.
> So was the time taken to run "time ./test | cat".
>
> Make of all that what you will.

Re: Why does C allow structs to have a tag?

<2da5e769-c64f-4817-82df-92d8c2b78b6fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17855&group=comp.lang.c#17855

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:9e12:: with SMTP id h18mr16378931qke.269.1628522903914;
Mon, 09 Aug 2021 08:28:23 -0700 (PDT)
X-Received: by 2002:ac8:71d7:: with SMTP id i23mr19885305qtp.381.1628522903777;
Mon, 09 Aug 2021 08:28:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder1.cambriumusenet.nl!feed.tweak.nl!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Mon, 9 Aug 2021 08:28:23 -0700 (PDT)
In-Reply-To: <8d16684f-d1da-436e-8778-07e2adf99404n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=199.203.251.52; posting-account=ow8VOgoAAAAfiGNvoH__Y4ADRwQF1hZW
NNTP-Posting-Host: 199.203.251.52
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk> <sepii6$k2g$1@dont-email.me>
<871r73la1b.fsf@bsb.me.uk> <sequ10$55f$1@dont-email.me> <1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
<ser8jf$cd2$1@dont-email.me> <serct0$c90$1@dont-email.me> <8d16684f-d1da-436e-8778-07e2adf99404n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2da5e769-c64f-4817-82df-92d8c2b78b6fn@googlegroups.com>
Subject: Re: Why does C allow structs to have a tag?
From: already5...@yahoo.com (Michael S)
Injection-Date: Mon, 09 Aug 2021 15:28:23 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Michael S - Mon, 9 Aug 2021 15:28 UTC

On Monday, August 9, 2021 at 5:54:01 PM UTC+3, Malcolm McLean wrote:
> On Monday, 9 August 2021 at 15:08:44 UTC+1, David Brown wrote:
> > On 09/08/2021 14:55, Bart wrote:
> > > On 09/08/2021 11:59, Michael S wrote:
> > >> On Monday, August 9, 2021 at 12:54:51 PM UTC+3, Bart wrote:
> > >
> > >>> At 23Mcps, I don't know what tricks the terminal driver is doing to
> > >>> achieve that. Maybe it's writing into a virtual screen (a text-mode
> > >>> buffer not bit-mapped), and only updating the display intermittently. Or
> > >>> maybe its better at using whatever hardware acceleration exists.
> > >>>
> > >>
> > >> I'd guess, it's much simpler.
> > >> A Linux terminal maintains a big queue, which, in absence of special
> > >> commands from the user,
> > >> is polled by rendering thread on consumer end 50 or 60 times per second.
> > >> You can see a very similar behavior if you run your "slow" exe from
> > >> terminal (mintty.exe), supplied with msys2.
> > >>
> > >> I'd guess, something similar can be achieved with cmd.exe console by
> > >> using non-default console output mode
> > >> (see SetConsoleMode()) but I never tried it.
> > >
> > > Let's take this program:
> > >
> > > #include <stdio.h>
> > >
> > > int main(void) {
> > > for (int i=0; i<1000000; ++i) {
> > > printf("%d\n",i);
> > > }
> > > }
> > >
> > >
> > > On Windows, using normal-speed printf, it takes 88 seconds to print
> > > those 1 million numbers (about 80Kcps). But all of them get displayed.
> > > (The binary to text conversion, tested using sprintf, is 0.4 seconds of
> > > that.)
> > >
> > > How long does the program take on a normal Linux system? Does each of
> > > those one million numbers get displayed? Or is it only the last
> > > screenful at the time that polling for display update gets done.
> > >
> > > If not showing every number, and doing one million scroll operations,
> > > then I'd consider that cheating, and would render timings such as 7ms
> > > meaningless.
> > >
> > > (My program run with gcc and without setvbuf or other workarounds took 8
> > > minutes, or about 10Kcps, 8 times as slow as it could have been.
> > >
> > > This 8x accords with there being about 8 characters output per printf
> > > call, which include crlf (a detail which would make it marginally slower
> > > than Linux anyway).)
> > >
> > I've been mostly staying out of this conversation - I don't have a
> > Windows system available for any testing. However, I /can/ do some
> > timings on Linux.
> >
> > Testing in a terminal window on my desktop (Linux Mint with Mate, so
> > approximately Gnome 2), it took 2.1 seconds. All million numbers are
> > there, and I can scroll back through the window buffer to see them.
> > Running it multiple times did not affect the timing, though the buffer
> > for the terminal gets bigger as it still holds all the lines. (This is
> > not typical behaviour on Windows command-prompt windows.)
> >
> > Running on a Linux virtual console outside of X, it took 117 seconds on
> > the same system.
> >
> > Running within a "screen" environment, with a default 1000 line history,
> > it was 1.85 seconds - it seems likely that the shorter buffer made it
> > more efficient.
> >
> > None of that was using any special settings or commands - it's just the
> > program you gave, compiled with gcc 9 out of the box, no flags.
> >
> > Piping the output into a file (6.6 million characters), to test the
> > speed without rendering the text, was about 0.09 seconds.
> >
> > Timing for "cat" on this file, in a terminal window, was about 1 second.
> > So was the time taken to run "time ./test | cat".
> >
> > Make of all that what you will.
> >
> On a modern desktop system, parsing a printf format string, applying the
> arguments, and creating a sequence of characters to pass to stdout doesn't
> take much time.

Funny that you are saying that.
Waiting for printf to finish writing to file (on decent SSD, nontheless, so I/O does not appears
to be a major bottleneck) is what made my today's job uncomfortable.
printf of 180M floating point numbers takes more than 2 minutes which is quite disruptive
to a workflow.

> It's what happens after that stage that accounts for the
> dufferences, which can be a factor of hundreds of thousands. Scrolling
> a bit-mapped display on the CPU on every line write is going to be much
> much slower than discarding the characters.

Re: Why does C allow structs to have a tag?

<87r1f2k4bc.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17856&group=comp.lang.c#17856

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 09 Aug 2021 16:47:51 +0100
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <87r1f2k4bc.fsf@bsb.me.uk>
References: <s9iea5$n5c$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
<sequ10$55f$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="196fca43467c90615119474f2257b729";
logging-data="5385"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/kVTxtA7rVitUZPiRySDhrQPQUARCA6gw="
Cancel-Lock: sha1:6pcC6+zeC5kplxEf0jnnmA3OBjI=
sha1:Iq5SKGwt/MnXrgv7+inWZPnPWHI=
X-BSB-Auth: 1.89ab50cf0238e9307a1e.20210809164751BST.87r1f2k4bc.fsf@bsb.me.uk
 by: Ben Bacarisse - Mon, 9 Aug 2021 15:47 UTC

Bart <bc@freeuk.com> writes:

> On 09/08/2021 01:46, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:
>>
>>> On 08/08/2021 22:17, Ben Bacarisse wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>
>>>>> The 'problem' is with clang/gcc calling 'printf'. All compilers are
>>>>> told to use printf, yet only these two compilers end up being slow.
>>>> I thought you said the problem goes away when the output is redirected?
>>>> gcc and clang don't generate code that does not call printf when the
>>>> output is redirected.
>>>
>>> I thought I explained what might have been happening: gcc might end up
>>> calling a routine in msvcrt that works a character at a time, rather
>>> than a string at a time. And the former might be slower when sent to
>>> the console so you don't see a problem with file output.
>> gcc is a compiler. It generates code that calls printf or similar.
>
> Actually, it doesn't. As I said, it calls an inline version of printf
> in its stdio.h, which ends up calling __mingw_vfprintf.

"... or similar". I did not want to have to list all the possible
printf-like functions (some of which are going to be internal ones like
this) that it might call.

>> After that, what happens is nothing to do with gcc.
>
> You're still trying to play that card.

Curious spin. My spin: it's called using words correctly. There is no
doubt you have a terrible C implementation (well, two actually, since
you also report absurdly slow times for what you call "tcc"), but I
don't see any evidence that gcc (or tcc for that matter) is the problem.

If you wanted to fix it, you'd have to know what components are really
contributing to the times you see.

--
Ben.

Re: Why does C allow structs to have a tag?

<seritq$kjb$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17857&group=comp.lang.c#17857

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 16:51:18 +0100
Organization: A noiseless patient Spider
Lines: 64
Message-ID: <seritq$kjb$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
<sequ10$55f$1@dont-email.me>
<1940b600-39e9-4f6c-b194-b7fa2dcf4c27n@googlegroups.com>
<ser8jf$cd2$1@dont-email.me> <serct0$c90$1@dont-email.me>
<16c39c11-53c7-46bc-9a0a-dfd8684a52can@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 15:51:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="21099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/aX0NetxdhTeQnzYdU1Y3KPipasvM/AfM="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:nsR+UosLvjCmrnutzHHeh9g5S+0=
In-Reply-To: <16c39c11-53c7-46bc-9a0a-dfd8684a52can@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-2, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 15:51 UTC

On 09/08/2021 16:19, Michael S wrote:
> On Monday, August 9, 2021 at 5:08:44 PM UTC+3, David Brown wrote:
>> On 09/08/2021 14:55, Bart wrote:
>>> On 09/08/2021 11:59, Michael S wrote:

>>> How long does the program take on a normal Linux system? Does each of
>>> those one million numbers get displayed? Or is it only the last
>>> screenful at the time that polling for display update gets done.
>>>
>>> If not showing every number, and doing one million scroll operations,
>>> then I'd consider that cheating, and would render timings such as 7ms
>>> meaningless.

>> I've been mostly staying out of this conversation - I don't have a
>> Windows system available for any testing. However, I /can/ do some
>> timings on Linux.
>>
>> Testing in a terminal window on my desktop (Linux Mint with Mate, so
>> approximately Gnome 2), it took 2.1 seconds. All million numbers are
>> there, and I can scroll back through the window buffer to see them.
>
> Yes, they are there, in the buffer. But absolute majority of them they quite certainly never were seen on display.
> It's just physically impossible, considering that display's vertical refresh
> rate is measured in dozens per second.

I don't know exactly how today's displays work. But in the past
certainly, you usually had some dedicated video memory, which is what
your application wrote into via OS calls.

There was a separate circuit which scanned that video memory once per
frame to update the physical display (CRT, whatever).

So it was quite possible to update the video memory faster than the
display could be updated. So that it wouldn't show all the output even
if you filmed the display and played it back in slow motion.

What takes the time is rendering text into that video memory, and also
scrolling that window for each new line.

What's in question is whether the Linux drivers bother rendering every
single change, asynchronously from the display frame rate, or only do so
once per frame. So it may show 1 to 60 (for 60 rows) and the next frame
it might show rows 1000 to 1059 which are the last 60 rows in the /text/
buffer.

It's possible that Windows also does something of the sort, but that
other parts are slow (and slower than the frame rate) so that you end up
seeing all the output.

However the discussion is about how some compilers make the display even
slower than it is.

>
>> Running it multiple times did not affect the timing, though the buffer
>> for the terminal gets bigger as it still holds all the lines. (This is
>> not typical behaviour on Windows command-prompt windows.)
>>
>
> Much worse than "not typical".
> For both cmd.exe and powershell not just an "out-of-the-box" default is very short (although less short for powershell), but configurable maximum is also short - 9999 lines.

The scrolling buffer I use is the same height as the console window - 60
lines. (Otherwise various bugs manifest themselves.)

Re: Why does C allow structs to have a tag?

<serk0o$bc0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17858&group=comp.lang.c#17858

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 17:09:56 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <serk0o$bc0$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<sepii6$k2g$1@dont-email.me> <871r73la1b.fsf@bsb.me.uk>
<sequ10$55f$1@dont-email.me> <87r1f2k4bc.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 16:10:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7aad62d735c9e343cb24fda0a66244a5";
logging-data="11648"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZfJJ1EKijaO4MEIbZasVuODKPKVbbELY="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:UBjNxepNNqUH8b9ImGZXWt32ZUQ=
In-Reply-To: <87r1f2k4bc.fsf@bsb.me.uk>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-2, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 16:09 UTC

On 09/08/2021 16:47, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 09/08/2021 01:46, Ben Bacarisse wrote:

>>> After that, what happens is nothing to do with gcc.
>>
>> You're still trying to play that card.
>
> Curious spin. My spin: it's called using words correctly. There is no
> doubt you have a terrible C implementation (well, two actually, since
> you also report absurdly slow times for what you call "tcc"),

tcc and bcc can print stuff to the console as fast as anything else.

If those 1000000 numbers were written to a file, and then I got the OS
to display that file using TYPE, it will take 88 or whatever seconds
just like the C program.

If you're getting silly times like 7msec, then that's likely an illusion
as discussed in recent posts, since you're only seeing a snapshot of the
output once per frame.

> but I
> don't see any evidence that gcc (or tcc for that matter) is the problem.

The problem here is NOT that Windows has slow console printing. All
language/all apps will share that problem.

The problem is that gcc and clang are N times slower than that, where N
is the average length of the string that printf ends up outputting.

There are workarounds but, out-of-the-box, that is what those products
do on their Windows installations.

(Note that Clang has a more official Windows binary download site than
gcc, but it is just as slow. Maybe it is just trying to be compatible.)

Re: Why does C allow structs to have a tag?

<k0fQI.22200$Fx8.6170@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17859&group=comp.lang.c#17859

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
From: nos...@dfs.com (DFS)
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
X-Mozilla-News-Host: news://usnews.blocknews.net
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
MIME-Version: 1.0
In-Reply-To: <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 113
Message-ID: <k0fQI.22200$Fx8.6170@fx45.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Mon, 09 Aug 2021 19:05:52 UTC
Organization: blocknews - www.blocknews.net
Date: Mon, 9 Aug 2021 15:05:51 -0400
X-Received-Bytes: 5221
 by: DFS - Mon, 9 Aug 2021 19:05 UTC

On 8/9/2021 4:29 AM, Michael S wrote:
> On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
>> On 8/8/2021 6:30 PM, Michael S wrote:
>>
>>> Bart and DFS are unique people with unique capabilities. DFS
>>> more so,
>> What are you babbling about?
>
> Your shared love to strange tools that wouldn't in top#5 list of
> choice of professional and likely not in top#10.

tcc was begat from contest-winning obfuscated C code.

https://bellard.org/otcc/

Can gcc or any other 'professional' product beat that? I think not.

>>> but Bart's ability to hit roadbles that almost nobody else hit
>>> also shouldn't be underestimated.
>> There's no reason for anyone to get different results that what
>> Bart and I experienced.
>>
>> Running Win10 21H1. Wanted a better compiler than tcc (0.9.27), so
>> I installed the gcc from:
>>
>> https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z
>>
>> (gcc 11.2.0)
>
> That loooks like mingw-64. The same compiler/libraries that I tried
> first and that finished the task in 20 msec - 1000 times faster than
> you (or Bart) reported.

I ran mine in a Windows cmd shell.

> AFAIK, it's C RTL is based on Microsoft's DLL that was originally
> distributed with VS2013. Recently, they (MSYS2 maintainers) added a
> variant of library that is called ucrt-something, probably based on
> more up to date Microsoft's DLL. I didn't try it yet.
>
> I didn't see the slowness because I was running it from msys2
> command window, i.e. the same environment in which that it was tested
> by maintainers. When I take generated exe file and try to run it in
> regular windows command window (cmd.exe) or in powershell window
> then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec
> in powereshell. When I changed the size of cmd window to
> "traditional" defaults of 80x25, it slowed down to 6 seconds.

You might look into ConEmu for Windows, a most excellent terminal
program. You can load up many different shells, including MSYS2 and WSL
Bash, very easily.

https://conemu.github.io/en/Tasks.html#add-default-tasks

>> $gcc -Wall source.c -o prog.exe
>>
>> created a huge executable that ran printf() very slowly.
>>
>
> Huge executive is due to presence of symbols. gcc -s (symbols
> stripped) is just big, not huge.

gcc: 85435
tcc: 15360

5.5x larger than the tcc version is huge.

> Slowness is due to interaction between startup code in mingw64
> library and windows command prompt environment, probably not
> provisioned by maintainers since they expect their console programs
> to be run under msys2.

OK.

> As said by several people here, under such combo stdout behaves as
> unbuffered. So, 160,000 system calls. By themselves, 160,000 system
> calls are not particularly slow, but Windows console subsystem seems
> obliged to redraw the whole window each time the character does not
> fit in window width. Or, may be, even more often, may be, once per
> character. So far I didn't figure out how to find exact details.
>
>>
>> Tried another one:
>>
>> https://github.com/skeeto/w64devkit/releases/tag/v1.8.0 (gcc
>> 11.1.0)
>>
>
> If you want to use msys2-maintained gcc compiler then I strongly
> recommend to stick to "official" msys2 distribution.
> https://www.msys2.org/

Haven't used it in a while, but I'll give it another try.

<snipped rest>

Re: Why does C allow structs to have a tag?

<sesbbk$63q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17860&group=comp.lang.c#17860

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 23:48:16 +0100
Organization: A noiseless patient Spider
Lines: 82
Message-ID: <sesbbk$63q$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se160r$o5c$1@dont-email.me>
<se1e2f$ht1$1@dont-email.me> <se1iev$hu3$1@dont-email.me>
<se1q6l$5ou$1@dont-email.me> <se26q0$dg5$1@dont-email.me>
<se3cvq$mpf$1@dont-email.me> <se3kpv$977$1@dont-email.me>
<se41h9$kbs$1@gioia.aioe.org> <sedtrl$irb$1@dont-email.me>
<see4ea$uop$1@dont-email.me> <see71a$gk4$1@dont-email.me>
<seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad>
<seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad>
<sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad>
<seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk>
<sepbrd$vg4$1@dont-email.me> <877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 9 Aug 2021 22:48:20 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="6266"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+t8u3yVHseXGGsYlGWSiugarIiYCOa+Rk="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:RxCft1D4O21JDWR1gDIQXjSOvaQ=
In-Reply-To: <94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-6, 9/8/2021), Outbound message
 by: Bart - Mon, 9 Aug 2021 22:48 UTC

On 09/08/2021 09:29, Michael S wrote:
> On Monday, August 9, 2021 at 3:03:15 AM UTC+3, DFS wrote:
>> On 8/8/2021 6:30 PM, Michael S wrote:
>>
>>> Bart and DFS are unique people with unique capabilities. DFS more so,
>> What are you babbling about?
>
> Your shared love to strange tools that wouldn't in top#5 list of choice of professional and likely not in top#10.

You just don't get it.

When I drive to the shops I like to use my hatchback, I don't need a
40-ton truck, or a 747, which are how big and cumbersome those
professional tools appear to me. (And if younger I'd jump on my bike.)

Who cares about the top 10 anyway? Where was the top 10 when I needed a
tiny, fast HLL language for my 8-bit micros which actually ran ON those
same micros? I've used my own languages ever since.

And when I have to play with C, I prefer my own small C compiler; you
know, that one with the faster printf than gcc/tdm.

> That loooks like mingw-64. The same compiler/libraries that I tried first and that finished the task in 20 msec - 1000 times faster than you (or Bart) reported.

A figure which I think you helped to debunk. But the issue at hand is
what to about the gcc version that runs under the exact same environment
as tcc.

> AFAIK, it's C RTL is based on Microsoft's DLL that was originally distributed with VS2013.
> Recently, they (MSYS2 maintainers) added a variant of library that is called ucrt-something,
> probably based on more up to date Microsoft's DLL. I didn't try it yet.
>
> I didn't see the slowness because I was running it from msys2 command window, i.e. the same environment in which that it was tested by maintainers.
> When I take generated exe file and try to run it in regular windows command window (cmd.exe)
> or in powershell window then I see extreme slowness - order of 4.5 sec in cmd.exe and 6.5 sec in powereshell.
> When I changed the size of cmd window to "traditional" defaults of 80x25, it slowed down to 6 seconds.

OK, that's more helpful. Now run tcc in the same way, or just use any
means to write the equivalent text to a file, and use TYPE to display
it. If that's much faster than doing it from the gcc-compiled program,
then you've reproduced the problem.

We don't need it 1000 times faster, just as fast as TYPE.

>
>>
>> $gcc -Wall source.c -o prog.exe
>>
>> created a huge executable that ran printf() very slowly.
>>
>
> Huge executive is due to presence of symbols. gcc -s (symbols stripped) is just big, not huge.
>
> Slowness is due to interaction between startup code in mingw64 library and windows command prompt environment,
> probably not provisioned by maintainers since they expect their console programs to be run under msys2.
>
> As said by several people here, under such combo stdout behaves as unbuffered. So, 160,000 system calls.
> By themselves, 160,000 system calls are not particularly slow, but Windows console subsystem seems obliged
> to redraw the whole window each time the character does not fit in window width.

Huh? The timings I get strongly suggest that something that should be
done per-string, is getting done per-character. Nothing to do with
window width, which is anyway a long way the other side of the C runtime
library they both end up calling.

>> gcc Windows: slow 3.15s
>> tcc Windows: quick 0.24s
>> gcc Linux : incredibly quick (like 0.01, no time to blink)
>>
>
> 0.01 I'd call o.k. rather than "incredibly quick"

So what is the upper limit of characters per second that can be
genuinely displayed in a Linux terminal window?

Assuming a character is a bitmapped 12x16 font, on a 24-bit display,
then writing one character cell (forget antialiasing and such) involves
writing 600 bytes to video memory. The 23Mcps figure of Ben's (I think
7ms to do 160K characters), would involve writing 13GB/s to video
memory. And that's without handling scrolling.

Re: Why does C allow structs to have a tag?

<87y29afah5.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17861&group=comp.lang.c#17861

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 09 Aug 2021 16:45:58 -0700
Organization: None to speak of
Lines: 15
Message-ID: <87y29afah5.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="30364"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wwdMLG6PQk1tcQp0jbBwd"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:GQXCz+w3o5ynzC/2ObSoAg+x/eg=
sha1:jPf5IaTyKCfsRBM7H784b+3ygtk=
 by: Keith Thompson - Mon, 9 Aug 2021 23:45 UTC

Bart <bc@freeuk.com> writes:
[...]
> And when I have to play with C, I prefer my own small C compiler; you
> know, that one with the faster printf than gcc/tdm.

Really? Your *compiler* implements printf? Not the runtime library?

Yes, the distinction matters.

[...]

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why does C allow structs to have a tag?

<seshh0$onu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17862&group=comp.lang.c#17862

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Tue, 10 Aug 2021 01:33:32 +0100
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <seshh0$onu$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 00:33:36 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b83644c731beaa3280d1c4bed68bddbb";
logging-data="25342"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18UI3OQdaC0YTzLCxM0siRGfLeO84RQBdc="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:TPf0SIASmNzQ8G4aVZkzv8WF3uI=
In-Reply-To: <87y29afah5.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210809-6, 9/8/2021), Outbound message
 by: Bart - Tue, 10 Aug 2021 00:33 UTC

On 10/08/2021 00:45, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> And when I have to play with C, I prefer my own small C compiler; you
>> know, that one with the faster printf than gcc/tdm.
>
> Really? Your *compiler* implements printf? Not the runtime library?
>
> Yes, the distinction matters.
>
> [...]
>

Not to most normal people, where a language and its implementation is
just expected to provide print facilities.

The same goes for C. And no the distinction doesn't really matter unless
you come from the Unix world, which apparently 'owns' C and gets to
decide all this stuff.

The 'faster' printf I'm refering to is the one inside msvcrt.dll, which
my gcc/tdm and clang/llvm don't appear capable of using without some
arm-twisting.

(Would it be that remarkable to implement a function like 'printf'?
That's the sort of thing I used to do all the time. But since it's
available in msvcrt.dll, there's no point in repeating stuff I've done
innumerable times.)

Re: Why does C allow structs to have a tag?

<87r1f2f7e1.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17863&group=comp.lang.c#17863

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 09 Aug 2021 17:52:38 -0700
Organization: None to speak of
Lines: 35
Message-ID: <87r1f2f7e1.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
<seshh0$onu$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4ba2c969ae0e906c6600fce7cdb6f53e";
logging-data="21340"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dWV1kGYscHdMG7joBvpA2"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:gkC9pbm3pMDgpa5yVk2JDsMN568=
sha1:BN6uLq83QRs7xUs/K7Ufy0lSoqc=
 by: Keith Thompson - Tue, 10 Aug 2021 00:52 UTC

Bart <bc@freeuk.com> writes:
> On 10/08/2021 00:45, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [...]
>>> And when I have to play with C, I prefer my own small C compiler; you
>>> know, that one with the faster printf than gcc/tdm.
>> Really? Your *compiler* implements printf? Not the runtime
>> library?
>> Yes, the distinction matters.
>> [...]
>
> Not to most normal people, where a language and its implementation is
> just expected to provide print facilities.
>
> The same goes for C. And no the distinction doesn't really matter
> unless you come from the Unix world, which apparently 'owns' C and
> gets to decide all this stuff.
>
> The 'faster' printf I'm refering to is the one inside msvcrt.dll,
> which my gcc/tdm and clang/llvm don't appear capable of using without
> some arm-twisting.
>
> (Would it be that remarkable to implement a function like 'printf'?
> That's the sort of thing I used to do all the time. But since it's
> available in msvcrt.dll, there's no point in repeating stuff I've done
> innumerable times.)

You continue to pretend not to understand the distinction between a
compiler and an implementation in a thread that demonstrates just how
important that distinction is.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why does C allow structs to have a tag?

<sesilm$e27$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17864&group=comp.lang.c#17864

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 9 Aug 2021 17:53:08 -0700
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <sesilm$e27$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <se3cvq$mpf$1@dont-email.me>
<se3kpv$977$1@dont-email.me> <se41h9$kbs$1@gioia.aioe.org>
<sedtrl$irb$1@dont-email.me> <see4ea$uop$1@dont-email.me>
<see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me>
<CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <sepbrd$vg4$1@dont-email.me>
<877dgvljpf.fsf@bsb.me.uk>
<2a1b4347-595a-469a-8df1-db64af9896acn@googlegroups.com>
<Wg_PI.6656$NQ1.5159@fx48.iad>
<94f47c65-5f5f-44d1-bc37-d51155624ae5n@googlegroups.com>
<sesbbk$63q$1@dont-email.me> <87y29afah5.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 10 Aug 2021 00:53:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="1d8cd4c6b177054f6a9d1e295d0dde89";
logging-data="14407"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18pdH6SpTeAIiyU8Vh7x6Bp"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.12.0
Cancel-Lock: sha1:oj9QLk/+nUqAdkXlCxCKiokcjLM=
In-Reply-To: <87y29afah5.fsf@nosuchdomain.example.com>
Content-Language: en-US
 by: Andrey Tarasevich - Tue, 10 Aug 2021 00:53 UTC

On 8/9/2021 4:45 PM, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> And when I have to play with C, I prefer my own small C compiler; you
>> know, that one with the faster printf than gcc/tdm.
>
> Really? Your *compiler* implements printf? Not the runtime library?
>
> Yes, the distinction matters.
>

While `printf` is certainly a library feature from the formal point of
view, it is not unusual to see it implemented as an intrinsic at
compiler level in modern implementations. GCC will happily replace

printf("Hello World\n");

with

puts("Hello World");

at compile-time.

--
Best regards,
Andrey Tarasevich

Pages:12345678910111213141516
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor