Re: perfomance question about bool variables in cxx

From: Bob Gezelter (gezelter_at_rlgsc.com)
Date: 07/22/05


Date: 22 Jul 2005 11:50:34 -0700

Larry,

With all due respect, I disagree with your explanation. If Klaus were
dealing with a large array of booleans, I would agree with you to the
extent that stepping through 8 times as much data (quadwords instead of
bytes) would generate inefficiencies.

In this case, the posted code generates a large number (42,949,672 to
be precise) of references to a single variable (quadword or byte,
respectively). In the case of the Alpha, Itanium, and almost all VAX
models, presuming that the data is naturally aligned by the compiler,
each reference should be a single cache or memory reference.

However, this simple experiment also illustrates the difficulties and
challenges of benchmarking.

- The compiler will, in many cases, optimize out the invariant
assignment code in the loop. Thus, with the correct compiler switches
used, the nearly 43 million iterations of the loop will be optimized to
a single instruction, executed exactly once.

- The fine level timing of this code, if it executes even a significant
number of iterations will be influenced by the other activity on the
CPU. Any event which affects cache hit rate, will effect the overall
performance of the code. To do this experiment effectively requires a
deeper analysis, and many test runs to get a significant certainty that
the numbers are not being influenced by random events. Science is
reproduceable, happenstance is not.

- There is a certain amount of processing that is not attributable to
the actual code under test. This includes image activation, the jacket
code in the test program, and image rundown. How much this is needs to
be computed, and subtracted from the test results to obtain an accurate
result. This overhead is the computational equivalent of the "tare
weight", the weight of an empty container when placed on a scale.

My apologies for running on a bit. I hope that this commentary is
helpful.

- Bob Gezelter, http://www.rlgsc.com



Relevant Pages

  • Re: How to convert Infix notation to postfix notation
    ... Even if we grant that, there remain others which are not matters of opinion, ... and cannot use it as a *reference*. ... Failure to do so causes common bugs. ... I do compiler stuff; we don't actually do our own compiler/libc ...
    (comp.lang.c)
  • Re: Using early-bound interface on a late-bound object
    ... > the compiler determines which interfaces to use, ... > supports the declared interface. ... >> help if someone can point me to some authoritative document or reference ... within customer shops when they mirrored this 'division' to keep their ...
    (microsoft.public.vb.general.discussion)
  • Re: Garbage Collection Eligibility and portability
    ... (in the parlance of compiler writers). ... There isn'tany way to get a given Lisp to act that way. ... that alters exactly when a variable reference to a memory location ceases holding it from collection. ... The other, which I've seen called "Aggressive garbage collection" in some articles on this behavior in C#/.Net, appears to make a memory location eligible the instant the last reference to the location is used. ...
    (comp.lang.lisp)
  • Re: Why we should (not?) have closures after all
    ... Programmers should have tools that can tell them as much as possible about their code's likely behavior. ... The wart can be used anywhere a type is used in declaring a reference ... The compiler does nothing special if a "can be null" reference is ... it would be nice if there was a variant of the "assert" statement that was always enabled and threw IllegalArgumentException instead of AssertionError. ...
    (comp.lang.java.programmer)
  • Re: Late Binding Question
    ... I still don't understand why the compiler thinks this is late bound?? ... I never did get what all the fuss about late binding is? ... "Microsoft.Office.Interop.Excel" reference in the Dot Net tab. ... Obviously the PIAs (primary interop assemblies) are ...
    (microsoft.public.dotnet.languages.vb)