Excessive Inlining

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ian Collins

    #16
    Re: Excessive Inlining

    JohnQ wrote:
    "James Kanze" <james.kanze@gm ail.comwrote in message
    news:1175348422 .117474.327060@ p15g2000hsd.goo glegroups.com.. .
    >
    Most coding guidelines I've seen ban inline functions
    completely, for this reason."
    >
    ************* (I hate it when OE refuses to quote correctly!) ***********
    >
    Then either get a better client, or do what the other poor unfortunate
    OE users do to quote correctly.
    Which begs the question: why is there no 'outline' keyword? Combined with
    code-folding editors, it would make it easier to organize some class header
    that have just a few or one outline function(s) (one file instead of 2 to
    manage). Most compilers do seem to have an "outline all inline functions"
    switch though.
    What purpose would it serve?
    I agree that in general, inlining functions is bad because it increases
    dependencies.
    Nonsense, C++ would be pretty neutered without inlining of trivial
    methods. Just compare the performance of an application with inlining
    off compared to the same code with it on.

    --
    Ian Collins.

    Comment

    • JohnQ

      #17
      Re: Excessive Inlining


      "Ian Collins" <ian-news@hotmail.co mwrote in message
      news:578andF2bm 6deU9@mid.indiv idual.net...
      JohnQ wrote:
      >"James Kanze" <james.kanze@gm ail.comwrote in message
      >news:117534842 2.117474.327060 @p15g2000hsd.go oglegroups.com. ..
      >>
      >Most coding guidelines I've seen ban inline functions
      >completely, for this reason."
      >>
      >************ * (I hate it when OE refuses to quote correctly!) ***********
      >>
      Then either get a better client, or do what the other poor unfortunate
      OE users do to quote correctly.
      >
      >Which begs the question: why is there no 'outline' keyword? Combined with
      >code-folding editors, it would make it easier to organize some class
      >header
      >that have just a few or one outline function(s) (one file instead of 2 to
      >manage). Most compilers do seem to have an "outline all inline functions"
      >switch though.
      >
      What purpose would it serve?
      Reduction of the number of source files.
      >
      >I agree that in general, inlining functions is bad because it increases
      >dependencies .
      >
      Nonsense, C++ would be pretty neutered without inlining of trivial
      methods.
      I wasn't talking about trivial methods. I was talking, obviously, about
      functions that required additional header files.

      John


      Comment

      • James Kanze

        #18
        Re: Excessive Inlining

        On Mar 31, 4:03 pm, "Alf P. Steinbach" <a...@start.now rote:
        * James Kanze:
        On the other hand, most (but not all) compilers require the
        definition of the function to be present in the compilation unit
        in order to inline. Which, of course, introduces significant
        compiler dependencies, and has a significant negative effect on
        programmer productivity.
        Does it?
        Measurably.
        General rule: "of course", "as we all know", and the like, most likely
        mean "fishy statement ahead".
        In this case, it means something that any programmer with
        experience has run into. At least, if he's worked on programs
        of any reasonable size.
        Most coding guidelines I've seen ban inline functions
        completely, for this reason.
        No template programming, then...
        Not at the application level, no.

        --
        James Kanze (Gabi Software) email: james.kanze@gma il.com
        Conseils en informatique orientée objet/
        Beratung in objektorientier ter Datenverarbeitu ng
        9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

        Comment

        • James Kanze

          #19
          Re: Excessive Inlining

          On Mar 31, 10:52 pm, Ian Collins <ian-n...@hotmail.co mwrote:
          James Kanze wrote:
          On Mar 30, 7:36 pm, "LuB" <lutherba...@ya hoo.comwrote:
          >How judicious ought one be when inlining small methods.
          That's simple: you never inline anything until the profiler says
          you must.
          Considering 'inline' is a hint and modern compilers will inline where
          they see fit, that's kind of a meaningless statement. Or are you
          referring to changing the code, bringing functions into the current
          compilation unit for example?
          I'm refering to the use of the "inline" keyword, of course.
          You're right that some modern compilers will inline without it,
          across compilation units, and according to the profiler data.
          Most coding guidelines I've seen ban inline functions
          completely, for this reason.
          Odd, I've never seen that. As Alf said, it would make using templates
          kind of hard!
          It does.

          As with any rule, it can be violated when there are overriding
          reasons to do so. But these are rare in application code, and I
          can't remember every having seen a template definition in
          application code in production software.

          In practice, this isn't that restricting. "Applicatio n"
          generally means dealing with known types anyway, unless you need
          dynamic dispatch. Templates tend to be restricted to lower
          level, very stable libraries. Libraries that are considered so
          fundamental that 1) upgrading to a more recent version is
          considered a major undertaking, much like moving to a new
          version of the compiler and 2) if you do it, you recompile
          everything and run the entire regression test suite again,
          before going further.

          --
          James Kanze (Gabi Software) email: james.kanze@gma il.com
          Conseils en informatique orientée objet/
          Beratung in objektorientier ter Datenverarbeitu ng
          9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

          Comment

          • Alf P. Steinbach

            #20
            Re: Excessive Inlining

            * James Kanze:
            On Mar 31, 4:03 pm, "Alf P. Steinbach" <a...@start.now rote:
            >* James Kanze:
            >
            >>On the other hand, most (but not all) compilers require the
            >>definition of the function to be present in the compilation unit
            >>in order to inline. Which, of course, introduces significant
            >>compiler dependencies, and has a significant negative effect on
            >>programmer productivity.
            >
            >Does it?
            >
            Measurably.
            >
            >General rule: "of course", "as we all know", and the like, most likely
            >mean "fishy statement ahead".
            >
            In this case, it means something that any programmer with
            experience has run into. At least, if he's worked on programs
            of any reasonable size.
            I think that must be specific to the environment(s) you're used to,
            and/or a statistical correlation between not-abiding-by-rules and low
            quality code (which would not be surprising). I've seen the latter
            effect, but not any problem from inlining per se. However, the few
            sizeable C++ systems I've worked on have had far more serious problems,
            obscuring any possible effect from inlining.

            When you write "significan t compiler dependencies" I think you mean
            public module dependencies, i.e. undesirable public coupling, dragging
            in headers that aren't really needed for the module's interface.

            One way to deal with that is to focus on the undesirable coupling
            instead of a language feature that one thinks is causing it.

            >>Most coding guidelines I've seen ban inline functions
            >>completely, for this reason.
            >
            >No template programming, then...
            >
            Not at the application level, no.
            ITYM that any template programming is by definition not part of the
            application level. Then, not surprisingly, the application level turns
            out to be a template free zone, except for use of (by definition)
            library templates.

            --
            A: Because it messes up the order in which people normally read text.
            Q: Why is it such a bad thing?
            A: Top-posting.
            Q: What is the most annoying thing on usenet and in e-mail?

            Comment

            • Ian Collins

              #21
              Re: Excessive Inlining

              James Kanze wrote:
              On Mar 31, 10:52 pm, Ian Collins <ian-n...@hotmail.co mwrote:
              >
              >>James Kanze wrote:
              >>
              >>>On Mar 30, 7:36 pm, "LuB" <lutherba...@ya hoo.comwrote:
              >
              >>>>How judicious ought one be when inlining small methods.
              >
              >>>That's simple: you never inline anything until the profiler says
              >>>you must.
              >
              >>Considering 'inline' is a hint and modern compilers will inline where
              >>they see fit, that's kind of a meaningless statement. Or are you
              >>referring to changing the code, bringing functions into the current
              >>compilation unit for example?
              >
              I'm refering to the use of the "inline" keyword, of course.
              You're right that some modern compilers will inline without it,
              across compilation units, and according to the profiler data.
              >
              I see. In practice, I have found the "inline" keyword to be of little
              use, the compiler is free to ignore it and in most case one has to jump
              through hoops to get the compiler to inline a function that it doesn't
              consider appropriate. So I never use it.
              >
              >>>Most coding guidelines I've seen ban inline functions
              >>>completely , for this reason.
              >
              >>Odd, I've never seen that. As Alf said, it would make using templates
              >>kind of hard!
              >
              It does.
              >
              As with any rule, it can be violated when there are overriding
              reasons to do so. But these are rare in application code, and I
              can't remember every having seen a template definition in
              application code in production software.
              >
              I guess that's a point of style, or I don't write what you consider
              "Applicatio n" code. I invariably break into templates before too long.
              Just about everything I have ever written contains at least some
              components that are generic.

              If you exclude templates, do you also exclude the standard library?
              >
              --
              James Kanze (Gabi Software) email: james.kanze@gma il.com
              >
              Still broken!

              --
              Ian Collins.

              Comment

              • Dave Rahardja

                #22
                Re: Excessive Inlining

                On 1 Apr 2007 03:37:19 -0700, "James Kanze" <james.kanze@gm ail.comwrote:
                >On Mar 31, 10:52 pm, Ian Collins <ian-n...@hotmail.co mwrote:
                >James Kanze wrote:
                On Mar 30, 7:36 pm, "LuB" <lutherba...@ya hoo.comwrote:
                >
                >>How judicious ought one be when inlining small methods.
                >
                That's simple: you never inline anything until the profiler says
                you must.
                >
                >Considering 'inline' is a hint and modern compilers will inline where
                >they see fit, that's kind of a meaningless statement. Or are you
                >referring to changing the code, bringing functions into the current
                >compilation unit for example?
                >
                >I'm refering to the use of the "inline" keyword, of course.
                >You're right that some modern compilers will inline without it,
                >across compilation units, and according to the profiler data.
                Some compilers I've worked with use the "inline" keyword to bias the "inlining
                score" that is used to determine if a function is going to be inlined.

                Most of the compilers I've worked with require the code to be visible in the
                compilation unit for the inlining to take place (i.e. no link-time inlining).
                In such cases, the "inline" keyword is required to prevent the "multiple
                definition" error from arising.

                >
                Most coding guidelines I've seen ban inline functions
                completely, for this reason.
                >
                >Odd, I've never seen that. As Alf said, it would make using templates
                >kind of hard!
                >
                >It does.
                >
                >As with any rule, it can be violated when there are overriding
                >reasons to do so. But these are rare in application code, and I
                >can't remember every having seen a template definition in
                >application code in production software.
                >
                >In practice, this isn't that restricting. "Applicatio n"
                >generally means dealing with known types anyway, unless you need
                >dynamic dispatch. Templates tend to be restricted to lower
                >level, very stable libraries. Libraries that are considered so
                >fundamental that 1) upgrading to a more recent version is
                >considered a major undertaking, much like moving to a new
                >version of the compiler and 2) if you do it, you recompile
                >everything and run the entire regression test suite again,
                >before going further.
                I disagree with your assessment, but I suppose it depends on your application
                domain. I find that almost all of the "applicatio n" code I've worked on use
                templates at the application level.

                Do you mean that you don't _use_ templates at the application level (not even
                using their definitions from a library), or that you merely don't _define_
                application-level templated entities?

                -dr

                Comment

                Working...