Mystery: static variables & performance

J

jacob navia

Mark Shelor said:
Perhaps
also is has to do with the register assignment algorithm working
differently when such variables change their storage class. It's hard
to be believe that accessing memory in one location versus another would
result in a 30% decrease in performance, unless of course the memory
values were no longer being cached in registers.

That is the central point.
Maybe (for whatever reasons) the compiler can't cache static variables
in registers.
If another thread runs the same code modifying the same static
variable,
the register cached value would not be synchronized with the
memory value and a mess would result.

Some compilers could ignore this (rather remote) possibility and would
cache the variable in a register, and others would not.

This would be easy to see by analyzing the generated code
 
J

jacob navia

A good test for this would be to declare the variable
volatile and see if all compilers agree. If they do so, it means
that the performance lost is a consequence of register
caching being not done when the variable is static.
 
M

Mike Wahler

Mark Shelor said:
Your reasoning is spurious.

As you indicate below with your own words, it's yours that's
spurious.
This is the group that likes to have
extended discussions on whether it's possible to calculate 73! using C.
If I were an idiot, I'd feel perfectly at home here.

A person who describes the preferences of a group of virtually
thousands of people who participate in a several-years old newsgroup
(whose archives are freely available) based upon a single recent
thread, authored by a very small number of those people, is, well,
imo an 'idiot'. :)

*Before* posting here again, *please* read (and observe) this
document:
http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html

Read my lips:

This newsgroup discusses the ISO standard C language.
Your query was *not* about the C language.

-Mike
 
M

Mark Shelor

Mike said:
A person who describes the preferences of a group of virtually
thousands of people who participate in a several-years old newsgroup
(whose archives are freely available) based upon a single recent
thread, authored by a very small number of those people, is, well,
imo an 'idiot'. :)


If you'll invest the effort to track the entire thread, you'll see that
the "idiot" epithet was not hurled originally by me. However, my use of
it was relatively fair and measured by comparison.

*Before* posting here again, *please* read (and observe) this
document:
http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html


Before posting again to this thread, it might behoove you to try and
contribute something technically rather than just issuing orders. The
world is postmodern now. Why don't you make an effort to join the rest
of us? You'll enjoy it.

Read my lips:

This newsgroup discusses the ISO standard C language.
Your query was *not* about the C language.


If you put down your copies of the standards for the moment and slowly
back away from the table, you'll see that it has everything to do with
the C language: but perhaps in a way that's more subtle than what you're
accustomed to. This is giving you the opportunity to grow, if you
decide to take advantage of it.

Despite the shrill squeaks from the peanut gallery, posting my query to
this newsgroup had very positive results. I've received several
enlightened suggestions through responses and private emails.

So, no, I don't by any means condemn this newsgroup. There are
obviously some highly intelligent and experienced people among your ranks.

Regards, Mark
 
M

Mike Wahler

Mark Shelor said:
If you'll invest the effort to track the entire thread,

If *you* would make the effort to track the entire *newsgroup*
(as well as reading its 'welcome message'), you'd get a much
better idea of its nature and purpose.
you'll see that
the "idiot" epithet was not hurled originally by me. However, my use of
it was relatively fair and measured by comparison.

You're entitled to your opinion of course.
Before posting again to this thread,

You didn't read the document at that link, did you?
it might behoove you to try and
contribute something technically

This group's archives can attest to my contributions here.
rather than just issuing orders.

I have issued no orders at all, I simply offered some good advice.
Of course you're free to observe or ignore it.
The
world is postmodern now.

That's a meaningless statement.
Why don't you make an effort to join the rest
of us?

Us? Who else are you referring to?
You'll enjoy it.

I long ago 'joined' with my fellow programmers here in discussing
the topic of this group: ISO standard C. Judging from your behavior
here, I have no interest in 'joining' *you*. And were I to do so,
I'm sure I would not enjoy it at all.

If you put down your copies of the standards

I own *one* copy of the *single* standard defining the C language.

This standard *defines* the C language which is the topic of this
newsgroup, so of course I refer to it quite often, and do use it
to determine if a particular issue is topical, if I don't know
already.
for the moment and slowly
back away from the table, you'll see that it has everything to do with
the C language:

If it's not defined by the standard, it's not part of the language.


but perhaps in a way that's more subtle than what you're
accustomed to.

'Subtlety' doesn't count in C. Either something is defined, or it's
not.
This is giving you the opportunity to grow, if you
decide to take advantage of it.

I'm doing just fine with regard to growth. It seems that it's *you*
who refuses to grow by refusing to acknowledge when you're wrong,
or to learn from your mistake (an off-topic post).
Despite the shrill squeaks from the peanut gallery,

Note that this 'peanut gallery' contains many world-class experts
in the C language, who could be of enormous benefit to you. But
now that you've insulted them, well, I wonder how willing they'll
be to help you in the future when you do have questions about C.

posting my query to
this newsgroup had very positive results.

Perhaps. Note that it has also had the negative result of branding
you as clueless as well as abusive.
I've received several
enlightened suggestions through responses and private emails.

All of which are necessarily off-topic for clc. Private email
is separate from this newsgroup and of course could contain anything
the correspondents desire without affecting the newsgroup, but
responses to your query other than an off-topic notice and
perhaps a redirection, are not appropriate for comp.lang.c
So, no, I don't by any means condemn this newsgroup.

I don't care whether you do or not. I find it very valuable to me,
which is why I take the time to defend it by challenging off-topic
material.
There are
obviously some highly intelligent and experienced people among your ranks.

And imo it's too bad you've gone and insulted them. You've probably
reduced considerably the chances of getting quality help from many
or all of them.



It seems to me that you do *not* have any regard for this newsgroup
or its participants.

-Mike
 
E

E. Robert Tisdale

Mike said:
> It seems to me that
you do *not* have any regard for this newsgroup
or its participants.

Mark Shelor is a new subscriber.
I can understand and tolerate his behavior in this thread --
mostly by ignoring him.
Your behavior, on the other hand, completely baffles me.
I would much rather that you brought Mark up to your level
than descending to his. :-(
 
M

Mark Shelor

Mike said:
Perhaps. Note that it has also had the negative result of branding
you as clueless as well as abusive.


There now, Mike, I hope that made you feel better.

I don't care whether you do or not. I find it very valuable to me,
which is why I take the time to defend it by challenging off-topic
material.


Where WOULD the newsgroup be without you, Mike? I'm glad you were on
duty this weekend. Perhaps our planet would have shifted off its axis
otherwise.

And imo it's too bad you've gone and insulted them. You've probably
reduced considerably the chances of getting quality help from many
or all of them.


Yes, I've already started to lose sleep over that dismal prospect.
Earlier this evening, I had just started to nod off when jarred awake by
a startling nightmare:

Bruce Willis was imploring me: "Mark! A huge meteor is hurtling toward
earth, and we're all doomed unless you can calculate 73! using Standard
C. UNIX bc and the GMP multiple-precision library just won't cut it,
man! You gotta use the Standard!!"

Alas, since I had insulted the august members of comp.lang.c, all of
mankind perished, and I alone was responsible.

Chilling stuff.

Mark
 
M

Mark McIntyre

If you'll invest the effort to track the entire thread, you'll see that
the "idiot" epithet was not hurled originally by me. However, my use of
it was relatively fair and measured by comparison.


Personally, I consider someone who walks into a butchers and asks for
loon pants, and who then, when told he's in a butchers, insists on his
right to make his purchase there, to be a bit of an idiot. YMMV. HTH,
HAND.
 
M

Mark McIntyre

If you put down your copies of the standards for the moment and slowly
back away from the table, you'll see that it has everything to do with
the C language:

Sorry, you fail the IQ test.
Despite the shrill squeaks from the peanut gallery, posting my query to
this newsgroup had very positive results. I've received several
enlightened suggestions through responses and private emails.

You presumably consider MSG's troll to be enlightened. Hmm.
So, no, I don't by any means condemn this newsgroup. There are
obviously some highly intelligent and experienced people among your ranks.

The one sensible thing you've posted in this thread.
 
M

Mark McIntyre

There now, Mike, I hope that made you feel better.

Why would it make Mike feel better, knowing that you've managed to
brand yourself clueless and abusive?

(Snip remaining dorkish and sarcastic attempts at insults.)
 
M

Mike Wahler

Mark Shelor said:
There now, Mike, I hope that made you feel better.




Where WOULD the newsgroup be without you, Mike? I'm glad you were on
duty this weekend. Perhaps our planet would have shifted off its axis
otherwise.

It seems some folks are beyond help.

*PLONK*

-Mike
 
S

Sidney Cadot

Mark said:

The newsgroup dedicated to the C implementation you're using.
I'd suggest you re-read the entire paragraph surrounding my string-copy
example to gain the proper context. You entirely missed the point, and
your response is pedantic, insulting, and, lo, off-topic.

You are right. I apologise for that.
Please, Sidney, set an example for us, and I'll be happy to follow.

Ok. I would urge you to think a bit about the actual points I made in my
previous post. The pedantry may have put you off, but I still feel I
made a valid point in noting the language-vs-implementation division.

Consider, for a moment, the possibility that you are wrong and we (the
people reacting to your insistance to discuss implementation-dependent
performance issues in this newsgroup) are right: the C language is
standardized in a way that very explicitly leaves performance issues
out. They are a matter of (quality of) _implementation_.

(And yes, I did consider the opposite.)

Best regards,


Sidney
 
M

Mark Shelor

Sidney said:
Consider, for a moment, the possibility that you are wrong and we (the
people reacting to your insistance to discuss implementation-dependent
performance issues in this newsgroup) are right: the C language is
standardized in a way that very explicitly leaves performance issues
out. They are a matter of (quality of) _implementation_.


OK, Sidney, I am considering it. I can certainly understand the premise
that a group might choose to entertain ONLY those questions that can be
resolved purely by a reading or clarification of (drum roll please) The
Standard. But how utterly boring, and what a waste of talent. It
reduces the newgroups participants to a mere gaggle of lawyers.

Secondly, responding to your earlier advice to post to the newsgroup
associated with my implementation, this is a non-starter. My question
spans the totality of C implementations. As author of a portable
cryptographic digest package, I cannot predict which C compiler a
particular user might actually employ to build the package. Yet it's
reasonable to want to ensure that--no matter which implementation is
chosen--the result will execute efficiently. And there are clever ways
to go about this that avoid the incremental approach of simply piling up
a mountain of #ifdef's in the code to handle specific cases. It's the
newsgroup's cleverness that I want to tap into, not its legal expertise.

The only common thread that connects this challenge is the C language
itself. The language was principally designed to offer a portable means
to produce efficient programs. For the newsgroup to eschew matters of
performance and efficiency is therefore short-sighted, and violates the
true spirit of the language.

Regards, Mark
 
M

Mark Shelor

Mark said:
Consider them attested for.


Thank you for attesting to his contributions. Frankly, I didn't want to
go to the trouble of looking them up myself.

Had Mr. Wahler been so kind as to include my entire remark, you would
have seen that I was suggesting that he contribute something technically
*to this thread*.

Regards, Mark
 
M

Mark Shelor

pete said:
"lurkers support me in email" is an old USENET joke.

Searched the web for "lurkers support me in email".
Results 1 - 10 of about 108. Search took 0.32 seconds.

http://www.bluejo.demon.co.uk/poetry/interstichia/lurkers.htm


Well, I certainly consider Christian Bau's and Jacob Navia's remarks in
this thread to have been particularly insightful and helpful. However,
I don't consider it proper to reveal identities or information relayed
by private email. But if this helps you to sustain an image of me as
less than honest, then more power to you. But I'd recommend that you
examine your own soul.

Regards, Mark
 
N

Nick Landsberg

Mark said:
OK, Sidney, I am considering it. I can certainly understand the premise
that a group might choose to entertain ONLY those questions that can be
resolved purely by a reading or clarification of (drum roll please) The
Standard. But how utterly boring, and what a waste of talent. It
reduces the newgroups participants to a mere gaggle of lawyers.

Secondly, responding to your earlier advice to post to the newsgroup
associated with my implementation, this is a non-starter. My question
spans the totality of C implementations. As author of a portable
cryptographic digest package, I cannot predict which C compiler a
particular user might actually employ to build the package. Yet it's
reasonable to want to ensure that--no matter which implementation is
chosen--the result will execute efficiently. And there are clever ways
to go about this that avoid the incremental approach of simply piling up
a mountain of #ifdef's in the code to handle specific cases. It's the
newsgroup's cleverness that I want to tap into, not its legal expertise.

The only common thread that connects this challenge is the C language
itself. The language was principally designed to offer a portable means
to produce efficient programs. For the newsgroup to eschew matters of
performance and efficiency is therefore short-sighted, and violates the
true spirit of the language.

Regards, Mark

I can argue both sides of this issue -

As someone who has been a performance consultant on many projects,
I find that the most egregious performance faux-pas are made not
at the language (code) level, but at the implementation level,
e.g. doing too many mallocs() rather than a buffer pool,
spawning excess threads, opening and closing sockets willy-nilly,
etc.

The C language allows you to shoot yourself in the foot in this
regard (and most languages do too, in this regard). What you write
is what you get in terms of performance.

If, on the other hand, all of the issues similar to the ones noted
above have been adressed, then it is legitimate to wonder which
C constructs are "best" for a given implementation. The answer
to this question is most likely to be dependent on the implementation
and the compiler. (is that redundant?) For example, I have worked
with compilers where "while(1)" was more efficient than "for(;;)"
and vice-versa. The delta was miniscule in comparison to the other
inefficiencies in my code.

On the other hand, if there ARE constructs which are inefficient,
I want to know about them in order to avoid them. So a question
to the language guru's may not be out of place
 
C

Christian Bau

Mark Shelor said:
OK, Sidney, I am considering it. I can certainly understand the premise
that a group might choose to entertain ONLY those questions that can be
resolved purely by a reading or clarification of (drum roll please) The
Standard.

If you know that the C Standard answers a question, then there is a good
chance that you know the answer as well. The other way round, if you
don't know the answer, then there is a good chance that you don't know
whether the C Standard gives an answer or not.
 
M

Mark McIntyre

Had Mr. Wahler been so kind as to include my entire remark, you would
have seen that I was suggesting that he contribute something technically
*to this thread*.

Given that its impossible to answer this thread in CLC, that would be hard
to do for anyone, even Dan Pop.

But mike already gave you very good and highly relevant contribution. You
chose to ignore it. Your loss.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top