Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
caveat... optimizer? the `zero and forget' thread on HN
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 31 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
dexen deVries  
View profile  
 More options Oct 29 2012, 5:58 am
Newsgroups: comp.os.plan9
From: dexen.devr...@gmail.com (dexen deVries)
Date: Mon, 29 Oct 2012 10:45:33 +0100
Local: Mon, Oct 29 2012 5:45 am
Subject: [9fans] caveat... optimizer? the `zero and forget' thread on HN
http://news.ycombinator.com/item?id=4711346

9fans says, ``no room in the compiler world for amateurs''. what's your take
on the above fubar?

--
dexen deVries

[[[↓][→]]]


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tlaro...@polynum.com  
View profile  
 More options Oct 29 2012, 6:25 am
Newsgroups: comp.os.plan9
From: tlaro...@polynum.com
Date: Mon, 29 Oct 2012 11:12:42 +0100
Local: Mon, Oct 29 2012 6:12 am
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

On Mon, Oct 29, 2012 at 10:45:33AM +0100, dexen deVries wrote:
> http://news.ycombinator.com/item?id=4711346

> 9fans says, ``no room in the compiler world for amateurs''. what's your take
> on the above fubar?

That when one does programming, one tries to have not fuzzy behavior,
that is to know exactly what the code does.

With some compilers, a programmer can make assumptions valid with the
sources and not anymore valid after compiler acrobatics, first of all
optimizations (and I thought volatile was precisely here to say: don't
try to guess ; leave this alone).

The worst being the GCC example when one has to explicitely disable some
acrobatics that are done by default. The correct behavior should be to
only switch on "features" when compiler is explicitely instructed to do
so (or, if some actions are done by default because it is proved that
this does not invalidate code assumptions, there should be a limit
number of rules explicitely stated in the man pages; the plan9 man
pages, and the Ken Thompson's style are remarquable for this: short
text/sources, with what is done and what is not guaranteed).

The man to texinfo transition has not improved the information but, on
the contrary, the size and complexity of informations, decreasing the
ratio signal/noise.

The first principle of safety (the theme of the article with zeroing
critical memory) is smallest and clearest sources. These are not the
bazaar aim. Neither on the compiler side.

--
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                      http://www.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 9:45 am
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 09:35:00 -0400
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon Oct 29 05:47:10 EDT 2012, dexen.devr...@gmail.com wrote:

> http://news.ycombinator.com/item?id=4711346

> 9fans says, ``no room in the compiler world for amateurs''. what's your take
> on the above fubar?

any sort of "advanced" code-moving optimization is confusing.  but the
way c/c++ are used in linux, bsd & osx, there is a noticable benefit to
optimizing calls away.  it takes smarts to optimize away those recursive
wrapper macros.  so they're in a bit of a pickle.

i just wonder if this isn't a race to the bottom.  tricks like this require
programmers to think harder about non-problems, and probablly write
defensive inlines, etc.  the compiler writers won't accept this slowdown
and will try to outwit the defensive inlines on the theory that programmers
aren't that keen.

LWN carries story on these sorts of self-inflicted wounds every so often.
the last one was on __access_once or something like that.

it goes without saying, i think a compiler that largely does what you
ask it to optimizes the scarce resource: developer time.

i'm sure you'll find smarter opinions from smarter people, though.  :-)

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 9:45 am
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 09:43:04 -0400
Local: Mon, Oct 29 2012 9:43 am
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

> The man to texinfo transition has not improved the information but, on
> the contrary, the size and complexity of informations, decreasing the
> ratio signal/noise.

from lions, i get only 7889 lines of code in the v6 kernel; the gcc
man page is 13000+, the last i checked.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 6:49 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 15:35:41 -0700
Local: Mon, Oct 29 2012 6:35 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 09:35:00 EDT erik quanstrom <quans...@quanstro.net>  wrote:

> On Mon Oct 29 05:47:10 EDT 2012, dexen.devr...@gmail.com wrote:
> > http://news.ycombinator.com/item?id=4711346

> > 9fans says, ``no room in the compiler world for amateurs''. what's your tak
> e
> > on the above fubar?

> any sort of "advanced" code-moving optimization is confusing.  but the
> way c/c++ are used in linux, bsd & osx, there is a noticable benefit to
> optimizing calls away.  it takes smarts to optimize away those recursive
> wrapper macros.  so they're in a bit of a pickle.

It has nothing to do with "how" C/C++ are used in linux, bsd &
osx -- you forgot windows!  The C standard allows a lot of
leeway in optimization.  Consider this:

        foo() {
            ...
            int x;
            int y[10];
            ...
            memset(y, 0, sizeof y);
        }

If x is never referred to, a correct program will never notice
if it is taken away. If address of x is never taken, it can be
allocated in a register (if there is a free one) to improve
performance. The same reasoning can be used to elide memset()
on y. Where do you draw the line? Any line will be arbitrary.

What the blog writer wanted to do (clearing memory after use)
is *not* guaranteed by the C standard so he can't expect help.
But it is easy to fool compilers to do what he wanted -- just
calling a user defined function that in turn calls memset did
the trick with gcc.

> it goes without saying, i think a compiler that largely does what you
> ask it to optimizes the scarce resource: developer time.

That is a separate issue.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Forsyth  
View profile  
 More options Oct 29 2012, 6:59 pm
Newsgroups: comp.os.plan9
From: charles.fors...@gmail.com (Charles Forsyth)
Date: Mon, 29 Oct 2012 22:47:02 +0000
Local: Mon, Oct 29 2012 6:47 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

He can fool it once, but can he fool it twice? Can he recompile?

On 29 October 2012 22:35, Bakul Shah <ba...@bitblocks.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 7:13 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 19:07:59 -0400
Local: Mon, Oct 29 2012 7:07 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon Oct 29 19:06:41 EDT 2012, ba...@bitblocks.com wrote:

> On Mon, 29 Oct 2012 22:47:02 -0000 Charles Forsyth <charles.fors...@gmail.com>  wrote:

> > He can fool it once, but can he fool it twice? Can he recompile?

> Why not.  Compilers never get wise to the ways of sneaky programmers!

feedback-based optimization.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 7:13 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 16:05:35 -0700
Local: Mon, Oct 29 2012 7:05 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 22:47:02 -0000 Charles Forsyth <charles.fors...@gmail.com>  wrote:

> He can fool it once, but can he fool it twice? Can he recompile?

Why not.  Compilers never get wise to the ways of sneaky programmers!

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 7:13 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 19:10:55 -0400
Local: Mon, Oct 29 2012 7:10 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon Oct 29 18:37:11 EDT 2012, ba...@bitblocks.com wrote:

my point was that the attitude that every optimization allowed is required is not
helpful and is in the end counter productive.

actually, to be a bit cute about it, i should announce the first
international obfuscated c compiler contest.  the goal of the contest
is to write a c99-compliant compiler that breaks every program in /sys/src/cmd.
the winner will be chosen based on highest percentage of programs broken,
with the tie going to the most devious tricks for remaining standards compliant
while missing the spirit completely.

> > it goes without saying, i think a compiler that largely does what you
> > ask it to optimizes the scarce resource: developer time.

> That is a separate issue.

actually, i think it *is* the issue.  

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Leimbach  
View profile  
 More options Oct 29 2012, 7:22 pm
Newsgroups: comp.os.plan9
From: leim...@gmail.com (David Leimbach)
Date: Mon, 29 Oct 2012 16:15:35 -0700
Local: Mon, Oct 29 2012 7:15 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

On Mon, Oct 29, 2012 at 4:07 PM, erik quanstrom <quans...@quanstro.net>wrote:

> On Mon Oct 29 19:06:41 EDT 2012, ba...@bitblocks.com wrote:
> > On Mon, 29 Oct 2012 22:47:02 -0000 Charles Forsyth <
> charles.fors...@gmail.com>  wrote:

> > > He can fool it once, but can he fool it twice? Can he recompile?

> > Why not.  Compilers never get wise to the ways of sneaky programmers!

> feedback-based optimization.

> - erik

Call me crazy, but I always felt compilers were there to emit code that
reflected what I wrote, not what it thinks it can do a better job writing
for me.  People complain that Go is not a good systems language due to the
garbage collector.  Maybe C isn't a good language due to all the places
where optimizers are allowed to break code.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 7:22 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 19:20:50 -0400
Local: Mon, Oct 29 2012 7:20 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

> Call me crazy, but I always felt compilers were there to emit code that
> reflected what I wrote, not what it thinks it can do a better job writing
> for me.  People complain that Go is not a good systems language due to the
> garbage collector.  Maybe C isn't a good language due to all the places
> where optimizers are allowed to break code.

the vodka is strong, but the meat is rotten.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 7:29 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 16:26:52 -0700
Local: Mon, Oct 29 2012 7:26 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 19:10:55 EDT erik quanstrom <quans...@quanstro.net>  wrote:

No disagreement there on "requiring" optimization. But my
point was that a programmer should understand the standard
rather than complain when he gets "surprised" due to his lack
of knowledge.

> actually, to be a bit cute about it, i should announce the first
> international obfuscated c compiler contest.  the goal of the contest
> is to write a c99-compliant compiler that breaks every program in /sys/src/cm
> d.
> the winner will be chosen based on highest percentage of programs broken,
> with the tie going to the most devious tricks for remaining standards complia
> nt
> while missing the spirit completely.

/sys/src/cmd follows plan9 c, not c99, right? But pick a
similar set of programs.  If this happens, I claim it would be
because programs assume something not guaranteed by the
compiler.

> > > it goes without saying, i think a compiler that largely does what you
> > > ask it to optimizes the scarce resource: developer time.

> > That is a separate issue.

> actually, i think it *is* the issue.  

Best way to save developer time is to program in a HLL and not
worry about bit fiddling. C is not a HLL.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 7:38 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 16:31:19 -0700
Local: Mon, Oct 29 2012 7:31 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 16:26:52 PDT Bakul Shah <ba...@bitblocks.com>  wrote:

> /sys/src/cmd follows plan9 c, not c99, right? But pick a
> similar set of programs.  If this happens, I claim it would be
> because programs assume something not guaranteed by the
> compiler.

Oops.  Meant to say "not guaranteed by the standard".

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 7:38 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 19:36:16 -0400
Local: Mon, Oct 29 2012 7:36 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

> No disagreement there on "requiring" optimization. But my
> point was that a programmer should understand the standard
> rather than complain when he gets "surprised" due to his lack
> of knowledge.

i agree that one should know the language.  but i'm not sure i'll
say it's the programmer's fault when the compiler does things to
the programmer.  that to me goes a bit too far.

> /sys/src/cmd follows plan9 c, not c99, right? But pick a
> similar set of programs.  If this happens, I claim it would be
> because programs assume something not guaranteed by the
> compiler.

and i can design a standards-compatable compiler that will break
most any c program.

this is similar to saying that i can design a namespace that will
break almost any plan 9 program.

what i think has broken down is common sense among compiler
writers.  they're too focused on being fast, and not focused enough
on being *useful*.

> > > > it goes without saying, i think a compiler that largely does what you
> > > > ask it to optimizes the scarce resource: developer time.

> > > That is a separate issue.

> > actually, i think it *is* the issue.  

> Best way to save developer time is to program in a HLL and not
> worry about bit fiddling. C is not a HLL.

this is a spurious argument, since we are in fact talking about c.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
andrey mirtchovski  
View profile  
 More options Oct 29 2012, 8:02 pm
Newsgroups: comp.os.plan9
From: mirtchov...@gmail.com (andrey mirtchovski)
Date: Mon, 29 Oct 2012 17:53:17 -0600
Local: Mon, Oct 29 2012 7:53 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

> the vodka is strong, but the meat is rotten.

wait, you're saying this as if it's a bad thing‽

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charles Forsyth  
View profile  
 More options Oct 29 2012, 8:02 pm
Newsgroups: comp.os.plan9
From: charles.fors...@gmail.com (Charles Forsyth)
Date: Mon, 29 Oct 2012 23:58:23 +0000
Local: Mon, Oct 29 2012 7:58 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

"But my point was that a programmer should understand the standard"

But suppose the standard does not evidently aim to be understood, in the
generally understood meaning of "understood",
or there are more words in the standard than will ever appear in the
programmer's own programs?
Worse! "Standard" doesn't imply a fixed point ("oh, that syntax/semantics
is so last year!").
I think looking into memset and deciding it's not worthwhile calling is
perhaps overly enthusiastic.
Actually, it's wrong, because it overlooks the side-effect, and an
optimiser for a language with side-effects
should take that into account.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kurt H Maier  
View profile  
 More options Oct 29 2012, 8:02 pm
Newsgroups: comp.os.plan9
From: kh...@intma.in (Kurt H Maier)
Date: Mon, 29 Oct 2012 19:59:57 -0400
Local: Mon, Oct 29 2012 7:59 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

On Mon, Oct 29, 2012 at 05:53:17PM -0600, andrey mirtchovski wrote:
> > the vodka is strong, but the meat is rotten.

> wait, you're saying this as if it's a bad thing‽

check your syslog for messages about references whizzing past your
terminal

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 8:47 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 17:35:01 -0700
Local: Mon, Oct 29 2012 8:35 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 19:36:16 EDT erik quanstrom <quans...@quanstro.net>  wrote:

> > No disagreement there on "requiring" optimization. But my
> > point was that a programmer should understand the standard
> > rather than complain when he gets "surprised" due to his lack
> > of knowledge.

> i agree that one should know the language.  but i'm not sure i'll
> say it's the programmer's fault when the compiler does things to
> the programmer.  that to me goes a bit too far.

Not a question of fault but IMHO a programmer, like a
carpenter or anyone who does real work, has to experiment and
learn the strengths and weaknesses of his tools of his trade
if he wants to become competent.

The language standard can only mandate what you can do within
the language.  For instace, if the blog writer had done this:

    ...
    memcpy(a, 0, sizeof a);
    for (i = 0; i < sizeof a; i++)
        assert(a[i] == 0);
    return 0;

}

He would have seen that every a[i] was indeed 0. But if you
use means external to the language (such as used a debugger or
look at the assembly language) to check side-effects, you get
to see the underside of optimization. Ugly, confusing and
possibly surprising. If you want to do something not covered
in the standard, learn what the compiler does and find a
compiler dependent way.

> > /sys/src/cmd follows plan9 c, not c99, right? But pick a
> > similar set of programs.  If this happens, I claim it would be
> > because programs assume something not guaranteed by the
> > compiler.

> and i can design a standards-compatable compiler that will break
> most any c program.

Care to give an example? I am genuinely interested. The C
standard is far from perfect but it has worked well enough.
[Where is doug gywn when we need him?]

> what i think has broken down is common sense among compiler
> writers.  they're too focused on being fast, and not focused enough
> on being *useful*.

I agree but I am afraid they do that because that is what the
market demands.  Pretty much most of the software that the
Internet runs on + used by most people + businesses uses C or
C++ so C/C++ and their standards have been *useful* (but see
below). Fast does matter when you scale up (a big company may
need 18K servers instead of 20K and that results in savings
and less heat generation).

If you want to whine, whine about the fact that *we* (all of
us) have lost common sense in pretty much every field.  Food,
medicine, media, politics, religion, consumption, you name it.

> > > > > it goes without saying, i think a compiler that largely does what you
> > > > > ask it to optimizes the scarce resource: developer time.

> > > > That is a separate issue.

> > > actually, i think it *is* the issue.  

> > Best way to save developer time is to program in a HLL and not
> > worry about bit fiddling. C is not a HLL.

> this is a spurious argument, since we are in fact talking about c.

Sorry but IMHO "saving developer time" & C don't mix well. I
am just pointing out what modern C is and how to survive, not
what it should be.  I gave up on that a long time ago!

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
cinap_len...@gmx.de  
View profile  
 More options Oct 29 2012, 9:05 pm
Newsgroups: comp.os.plan9
From: cinap_len...@gmx.de
Date: Tue, 30 Oct 2012 02:46:34 +0100
Local: Mon, Oct 29 2012 9:46 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
m(

--
cinap


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 9:05 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 17:52:48 -0700
Local: Mon, Oct 29 2012 8:52 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 23:58:23 -0000 Charles Forsyth <charles.fors...@gmail.com>  wrote:

> "But my point was that a programmer should understand the standard"

> But suppose the standard does not evidently aim to be understood, in the
> generally understood meaning of "understood",
> or there are more words in the standard than will ever appear in the
> programmer's own programs?

The C standard is not too hard to understand. For something
worse try one of those ITU standards! Try IEEE 802 standards!
I have had to read the Bridging standard many many more times
(compared to the C standard) to make sense of it.  The
standards *shouldn't* be so horrible but they are.  And one
does what is needed to get the job done.

> Worse! "Standard" doesn't imply a fixed point ("oh, that syntax/semantics
> is so last year!").
> I think looking into memset and deciding it's not worthwhile calling is
> perhaps overly enthusiastic.

I ask again. Who decides where the line is drawn? I think that
in a competitive environment the only thing that can restrain
people is the standard. Unfortunately.

> Actually, it's wrong, because it overlooks the side-effect, and an
> optimiser for a language with side-effects
> should take that into account.

They put in "volatile" to ensure side-effects happen. Hasn't
worked too well.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 9:05 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 21:01:52 -0400
Local: Mon, Oct 29 2012 9:01 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

> The C standard is not too hard to understand. For something
> worse try one of those ITU standards! Try IEEE 802 standards!
> I have had to read the Bridging standard many many more times
> (compared to the C standard) to make sense of it.  The
> standards *shouldn't* be so horrible but they are.  And one
> does what is needed to get the job done.

this is logical fallacy.

the fact that there are larger and more obtuse standards,
does not mean that the c standard is readable or understandable,
by their normal definitions.

> > Actually, it's wrong, because it overlooks the side-effect, and an
> > optimiser for a language with side-effects
> > should take that into account.

> They put in "volatile" to ensure side-effects happen. Hasn't
> worked too well.

that's incorrect.  it was a hack to try to sneak a memory
model in the side door.  side effects are something else entirely.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
erik quanstrom  
View profile  
 More options Oct 29 2012, 9:14 pm
Newsgroups: comp.os.plan9
From: quans...@quanstro.net (erik quanstrom)
Date: Mon, 29 Oct 2012 21:10:41 -0400
Local: Mon, Oct 29 2012 9:10 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon Oct 29 20:36:26 EDT 2012, ba...@bitblocks.com wrote:

you are arguing for a cartoon hammer that runs away when you're
not looking at it.

> > and i can design a standards-compatable compiler that will break
> > most any c program.

> Care to give an example? I am genuinely interested. The C
> standard is far from perfect but it has worked well enough.
> [Where is doug gywn when we need him?]

oh, there are a number of obvious under-handed tricks.  let's see,
for an intel compiler, change the structure padding to something bizarre
like 3 bytes.  that will break a large number of linux drivers.  (the 57711
for sure!)  rearrange structure elements other than the first.
you can change from signed-preserving to unsigned preserving.
that'll catch a lot of folks out.  do ones-complement arithmetic
(i believe that's still legal).  have 10-bit bytes. 20 bit shorts, 40 bit
ints, 45-bit longs and 80-bit vlongs.  (i'm not sure that's completely
legal, but you get the point.)  make pointers to different types different
sizes.  the list goes on.  the combinations are silly, too.  default
unsigned characters with unsigned preserving behavior.  good luck
debugging that!

and since you would allow compilers to mess with side effects, we could
have a genuine field day.

> > what i think has broken down is common sense among compiler
> > writers.  they're too focused on being fast, and not focused enough
> > on being *useful*.

> I agree but I am afraid they do that because that is what the
> market demands.  Pretty much most of the software that the
> Internet runs on + used by most people + businesses uses C or
> C++ so C/C++ and their standards have been *useful* (but see
> below). Fast does matter when you scale up (a big company may
> need 18K servers instead of 20K and that results in savings
> and less heat generation).

i don't understand your use of the world "useful".  to me, the c
standard has become like a political issue.  it's something to
game for personal advantage.

- erik


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kurt H Maier  
View profile  
 More options Oct 29 2012, 9:22 pm
Newsgroups: comp.os.plan9
From: kh...@intma.in (Kurt H Maier)
Date: Mon, 29 Oct 2012 21:21:02 -0400
Local: Mon, Oct 29 2012 9:21 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

On Mon, Oct 29, 2012 at 04:26:52PM -0700, Bakul Shah wrote:

> Best way to save developer time is to program in a HLL and not
> worry about bit fiddling. C is not a HLL.

Two problems with this:

1) Developer time is not worth saving, because developers are cheap and
they don't use their time very well in the first place.

2) C was a high-level language during the era where developer time was
worth saving.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bakul Shah  
View profile  
 More options Oct 29 2012, 11:18 pm
Newsgroups: comp.os.plan9
From: ba...@bitblocks.com (Bakul Shah)
Date: Mon, 29 Oct 2012 20:06:34 -0700
Local: Mon, Oct 29 2012 11:06 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN
On Mon, 29 Oct 2012 21:10:41 EDT erik quanstrom <quans...@quanstro.net>  wrote:

> you are arguing for a cartoon hammer that runs away when you're
> not looking at it.

That is an excellent definition of optimization!  Typical
optimizations:

- putting a variable in a register
- caching a value in a register
- moving a computation outside a loop
- inlining
- not doing something that is not going to be used
- reusing a register (so the old variable no longer exists)
- moving a computation to callsite from the called function
  (partial inlining)
- partial evaluation
- caching a result
- don't allocate a variable if not used

In all these cases, the generated code will look different
compared to when *no* optimization is done.

The issue again is, who draws the line? And where?  And is it
the same for every processor model? [An optimization on one
can be a pessimization on another]. Note that even the
simple flat memory model of C is an illusion.

The "stalin" Scheme to C compiler can do whole program
optimization and produces amazingly efficient programs --
often better than hand written C code. Letting it do the
optimization saves a lot of developer time, and more
importantly, one can write clear understandable code and not
have to hand optimize it into spaghetti code (where some
obscure bug can hide).  Now the compiler is slow so I would
only use it if I am going to run something for a very long
time.

I would argue that one should not put limits on what can be
optimized but should keep the language simple and clearly pin
down semantics as precisely as possible.

My head hurts! Clearly programs that break won't be standard
compliant :-)

> > > what i think has broken down is common sense among compiler
> > > writers.  they're too focused on being fast, and not focused enough
> > > on being *useful*.

> > I agree but I am afraid they do that because that is what the
> > market demands.  Pretty much most of the software that the
> > Internet runs on + used by most people + businesses uses C or
> > C++ so C/C++ and their standards have been *useful* (but see
> > below). Fast does matter when you scale up (a big company may
> > need 18K servers instead of 20K and that results in savings
> > and less heat generation).

> i don't understand your use of the world "useful".  to me, the c
> standard has become like a political issue.  it's something to
> game for personal advantage.

gcc etc. are used to deliver a lot of code that is used in
real word.  And without a standard there would've been lot
less interoperability and far more bugs.

You seem to be arguing for K&R as the standard or something
but we already tried that until 1989. A standard was needed
due to the success of C and with indepenedent implementations
that interpreted unwritten things in a different way from K&R.
I doubt Ritchie and co wanted to take an active and central
role (and I am not familiar with the history) but my guess
is only that could've kept the standard simple and readable.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Corey Thomasson  
View profile  
 More options Oct 29 2012, 11:18 pm
Newsgroups: comp.os.plan9
From: cthom.li...@gmail.com (Corey Thomasson)
Date: Mon, 29 Oct 2012 23:16:01 -0400
Local: Mon, Oct 29 2012 11:16 pm
Subject: Re: [9fans] caveat... optimizer? the `zero and forget' thread on HN

On 29 October 2012 23:06, Bakul Shah <ba...@bitblocks.com> wrote:

> gcc etc. are used to deliver a lot of code that is used in
> real word.  And without a standard there would've been lot
> less interoperability and far more bugs.

Most interoperability delivered by gcc comes from the fact that gcc is
widespread, not that the standard is effective. If it was we wouldn't need
to port gcc to everything.


You seem to be arguing for K&R as the standard or something


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 31   Newer >
« Back to Discussions « Newer topic     Older topic »