Mystery: static variables & performance

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mark McIntyre

    #16
    Re: Mystery: static variables & performance

    On Sat, 07 Feb 2004 05:35:32 -0700, in comp.lang.c , Mark Shelor
    <mshelor@comcas t.removeme.net> wrote:
    [color=blue]
    >Joona I Palaste wrote:
    >[color=green]
    >> But that would have been the wrong reply. This newsgroup is about the
    >> C language, not about implementations of it. Languages do not have
    >> speed. Implementations do. Therefore questions about efficiency are
    >> off-topic here.[/color]
    >
    >
    >If you believe it's off-topic, then don't reply. This is an unmoderated
    >group.[/color]

    actually, its more of a self-regulated group. Offtopic posts get one
    polite warning,
    [color=blue]
    >Also, your presumption of clean separability between language definition
    >and efficiency is naive at best, and fatally flawed at worst. The
    >creation and refinement of the C language is rooted in the desire to
    >achieve efficient portable programs.[/color]

    Define efficient. fast? compact? least code? fewest pagefaults? etc
    [color=blue]
    > Jack said, quite correctly, that the C standard does not define[color=green]
    >> efficiency concerns. Honestly, would you think it did? Would it make
    >> sense to define "operation X must be 2.5 times slower than operation Y,
    >> or else the implementation does not conform to the C standard"?[/color]
    >
    >No, because the people who created the language--and refined its
    >definition into a standard--are reasonably intelligent, unlike your
    >example.[/color]

    You miss the point entirely. The standard doesn't define these things,
    nor the efficiency of your example, because its ntirely system
    specific.
    [color=blue]
    >Nonetheless, if you have something constructive to contribute, then
    >please feel free to enlighten me. Otherwise, I recommend you take
    >Wittgenstein 's advice and simply remain silent.[/color]

    Round here, we ask offtopic posters politely to ask elsewhere. If you
    do't like that, then please feel free to remain silent.
    --
    Mark McIntyre
    CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
    CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

    Comment

    • Mark McIntyre

      #17
      Re: Mystery: static variables &amp; performance

      On Sat, 07 Feb 2004 17:04:58 -0700, in comp.lang.c , Mark Shelor
      <mshelor@comcas t.removeme.net> wrote:
      [color=blue]
      >MSG wrote:[/color]
      (stuff)>[color=blue]
      >
      >At long last ... an intelligent response. Thank you![/color]

      you might want to consider that MSG is bordering on becoming a troll
      here.

      (snip offtopic stuff)
      [color=blue]
      >Or, perhaps there are other explanations for why the performance is
      >impacted,[/color]

      The frobozz has lost its wheezle. Or possibly your core memory beads
      have slipped on the wires. Or you forgot to rub the cat with the
      amber before putting the static memory in your 380-Z.
      [color=blue]
      >which might suggest other ways of approaching the computation.
      > That's what I'm really after here.[/color]

      Then you're becoming an idiot. This is the wrong group.

      --
      Mark McIntyre
      CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
      CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


      ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
      http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
      ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

      Comment

      • Mark McIntyre

        #18
        Re: Mystery: static variables &amp; performance

        On Sat, 07 Feb 2004 17:34:47 -0700, in comp.lang.c , Mark Shelor
        <mshelor@comcas t.removeme.net> wrote:
        [color=blue]
        >You fail
        >to appreciate the fact that questions of portable efficiency ARE topical
        >to a discussion of the language.[/color]

        And you have had an answer. . Just because you don't like the answer
        doesn't mean its not true. But let me repeat, for the hard of hearing:
        "Standard C doesn't require any particular efficiency from any
        function or construct and so it ts impossible to answer your question.
        You need to ask in a group specialising in your platforms."
        [color=blue]
        >You are attempting to unilaterally[/color]

        FWIW, to be unilateral, there has to be only one person trying to do
        it. There's a /consensus/ here about this.
        [color=blue]
        >outlaw these questions because you lack the appropriate insight and
        >experience to answer them.[/color]

        ROFL !!!!! Do you know who you're referring to?


        --
        Mark McIntyre
        CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
        CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


        ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
        http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
        ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

        Comment

        • Christian Bau

          #19
          Re: Mystery: static variables &amp; performance

          In article <GtqdnQpSmoCw4L jdRVn-vw@comcast.com> ,
          Mark Shelor <mshelor@comcas t.removeme.net> wrote:
          [color=blue]
          > Nonetheless, the problem is not quite as simple as your queries imply.
          > The Digest::SHA module and underlying C code are designed to be as
          > portable as reasonably possible, since it's not known beforehand which
          > compiler(s) will be used to build it; the CPAN user community is quite
          > broad and diverse. Merely finding which code is most efficient for each
          > platform/compiler combination, and setting up the appropriate #ifdef's,
          > is like chipping away at an iceberg. Yet, there should be a way to
          > construct portable and highly efficient code in a general sense (i.e.
          > that works well across most machines).[/color]

          One possibility that I have used for highly time critical and relatively
          small code: Implement two or three versions of a function, each doing
          things in different ways that could influence speed in some way. Call
          these functions through a global variable containing a function pointer.
          The function pointer is initialised to point to a measuring function;
          that function will during the first x calls call one of your
          implementations and measure the time; after x calls it decides which one
          was fasted and replaces the function pointer with a pointer to the
          fastest function which is used for the rest of program execution.

          Comment

          • Mark Shelor

            #20
            Re: Mystery: static variables &amp; performance

            Mark McIntyre wrote:
            [color=blue]
            > The frobozz has lost its wheezle. Or possibly your core memory beads
            > have slipped on the wires. Or you forgot to rub the cat with the
            > amber before putting the static memory in your 380-Z.[/color]


            Hmm ... are those techniques mentioned in the C standards? Isn't your
            response off-topic? <g>

            [color=blue][color=green]
            >>which might suggest other ways of approaching the computation.
            >> That's what I'm really after here.[/color]
            >
            >
            > Then you're becoming an idiot. This is the wrong group.[/color]


            Your reasoning is 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.

            Regards, Mark

            Comment

            • jacob navia

              #21
              Re: Mystery: static variables &amp; performance

              "Mark Shelor" <mshelor@comcas t.removeme.net> wrote in message
              news:GtqdnQpSmo Cw4LjdRVn-vw@comcast.com. ..[color=blue]
              > Perhaps
              > also is has to do with the register assignment algorithm working
              > differently when such variables change their storage class. It's[/color]
              hard[color=blue]
              > to be believe that accessing memory in one location versus another[/color]
              would[color=blue]
              > result in a 30% decrease in performance, unless of course the memory
              > values were no longer being cached in registers.[/color]

              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


              Comment

              • jacob navia

                #22
                Re: Mystery: static variables &amp; performance

                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.


                Comment

                • Mike Wahler

                  #23
                  Re: Mystery: static variables &amp; performance

                  "Mark Shelor" <mshelor@comcas t.removeme.net> wrote in message
                  news:5Iudnf3bhe TSF7jdRVn-jQ@comcast.com. ..[color=blue]
                  >
                  > Your reasoning is spurious.[/color]

                  As you indicate below with your own words, it's yours that's
                  spurious.
                  [color=blue]
                  >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.[/color]

                  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:


                  Read my lips:

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

                  -Mike




                  Comment

                  • Mark Shelor

                    #24
                    Re: Mystery: static variables &amp; performance

                    Mike Wahler wrote:
                    [color=blue]
                    > 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'. :-)[/color]


                    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.

                    [color=blue]
                    > *Before* posting here again, *please* read (and observe) this
                    > document:
                    > http://www.angelfire.com/ms3/bchambl...me_to_clc.html[/color]


                    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.

                    [color=blue]
                    > Read my lips:
                    >
                    > This newsgroup discusses the ISO standard C language.
                    > Your query was *not* about the C language.[/color]


                    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

                    Comment

                    • Mike Wahler

                      #25
                      Re: [OT] Mystery: static variables &amp; performance

                      "Mark Shelor" <mshelor@comcas t.removeme.net> wrote in message
                      news:KdOdnZ5Ula fqTLjd4p2dnA@co mcast.com...[color=blue]
                      > Mike Wahler wrote:
                      >[color=green]
                      > > 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'. :-)[/color]
                      >
                      >
                      > If you'll invest the effort to track the entire thread,[/color]

                      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.
                      [color=blue]
                      >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.[/color]

                      You're entitled to your opinion of course.
                      [color=blue]
                      >
                      >[color=green]
                      > > *Before* posting here again, *please* read (and observe) this
                      > > document:
                      > > http://www.angelfire.com/ms3/bchambl...me_to_clc.html[/color]
                      >
                      >
                      > Before posting again to this thread,[/color]

                      You didn't read the document at that link, did you?
                      [color=blue]
                      >it might behoove you to try and
                      > contribute something technically[/color]

                      This group's archives can attest to my contributions here.
                      [color=blue]
                      >rather than just issuing orders.[/color]

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

                      That's a meaningless statement.
                      [color=blue]
                      > Why don't you make an effort to join the rest
                      > of us?[/color]

                      Us? Who else are you referring to?
                      [color=blue]
                      >You'll enjoy it.[/color]

                      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.

                      [color=blue]
                      >
                      >[color=green]
                      > > Read my lips:
                      > >
                      > > This newsgroup discusses the ISO standard C language.
                      > > Your query was *not* about the C language.[/color]
                      >
                      >
                      > If you put down your copies of the standards[/color]

                      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.
                      [color=blue]
                      >for the moment and slowly
                      > back away from the table, you'll see that it has everything to do with
                      > the C language:[/color]

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


                      [color=blue]
                      > but perhaps in a way that's more subtle than what you're
                      > accustomed to.[/color]

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

                      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).
                      [color=blue]
                      >
                      > Despite the shrill squeaks from the peanut gallery,[/color]

                      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.

                      [color=blue]
                      >posting my query to
                      > this newsgroup had very positive results.[/color]

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

                      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
                      [color=blue]
                      >
                      > So, no, I don't by any means condemn this newsgroup.[/color]

                      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.
                      [color=blue]
                      >There are
                      > obviously some highly intelligent and experienced people among your ranks.[/color]

                      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.

                      [color=blue]
                      >
                      > Regards,[/color]


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

                      -Mike



                      Comment

                      • E. Robert Tisdale

                        #26
                        Re: [OT] Mystery: static variables &amp; performance

                        Mike Wahler wrote:
                        [color=blue]
                        > It seems to me that
                        > you do *not* have any regard for this newsgroup
                        > or its participants.[/color]

                        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. :-(

                        Comment

                        • Mark Shelor

                          #27
                          Re: [OT] Mystery: static variables &amp; performance

                          Mike Wahler wrote:
                          [color=blue]
                          > Perhaps. Note that it has also had the negative result of branding
                          > you as clueless as well as abusive.[/color]


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

                          [color=blue]
                          > 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.[/color]


                          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.

                          [color=blue]
                          > 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.[/color]


                          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

                          Comment

                          • pete

                            #28
                            Re: Mystery: static variables &amp; performance

                            Mark Shelor wrote:
                            [color=blue]
                            > 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.[/color]

                            "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.



                            --
                            pete

                            Comment

                            • Mark McIntyre

                              #29
                              Re: Mystery: static variables &amp; performance

                              On Sat, 07 Feb 2004 23:04:36 -0700, in comp.lang.c , Mark Shelor
                              <mshelor@comcas t.removeme.net> wrote:
                              [color=blue]
                              >Mike Wahler wrote:
                              >[color=green]
                              >> 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'. :-)[/color]
                              >
                              >
                              >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.[/color]


                              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.


                              --
                              Mark McIntyre
                              CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
                              CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


                              ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                              http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                              ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

                              Comment

                              • Mark McIntyre

                                #30
                                Re: Mystery: static variables &amp; performance

                                On Sat, 07 Feb 2004 23:04:36 -0700, in comp.lang.c , Mark Shelor
                                <mshelor@comcas t.removeme.net> wrote:
                                [color=blue]
                                >Mike Wahler wrote:
                                >[color=green]
                                >> Read my lips:
                                >>
                                >> This newsgroup discusses the ISO standard C language.
                                >> Your query was *not* about the C language.[/color]
                                >
                                >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:[/color]

                                Sorry, you fail the IQ test.
                                [color=blue]
                                >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.[/color]

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

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

                                --
                                Mark McIntyre
                                CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
                                CLC readme: <http://www.angelfire.c om/ms3/bchambless0/welcome_to_clc. html>


                                ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                                http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                                ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

                                Comment

                                Working...