how to decrease link time

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

    how to decrease link time

    i know that pImpl idiom can decrease compile time, but Is there any
    good practice/idiom to decrease link time?

    any reference or any idea is appreciated

    thanks

  • red floyd

    #2
    Re: how to decrease link time

    baibaichen wrote:[color=blue]
    > i know that pImpl idiom can decrease compile time, but Is there any
    > good practice/idiom to decrease link time?
    >
    > any reference or any idea is appreciated
    >[/color]

    Link time is so minimal compared to compile time and totally negligible
    compared to run time.

    Design instead for maintainability . pImpl provides support for this, by
    divorcing implementation and interface. The compile time benefits (if
    any) are just icing on the cake.

    Comment

    • Shezan Baig

      #3
      Re: how to decrease link time

      baibaichen wrote:[color=blue]
      > i know that pImpl idiom can decrease compile time, but Is there any
      > good practice/idiom to decrease link time?
      >
      > any reference or any idea is appreciated[/color]



      The best advice I can give is do not create cyclic dependencies in your
      modules.

      Hope this helps,
      -shez-

      Comment

      • Dave Townsend

        #4
        Re: how to decrease link time


        "baibaichen " <baibaichen@gma il.com> wrote in message
        news:1136866265 .540050.153850@ f14g2000cwb.goo glegroups.com.. .[color=blue]
        > i know that pImpl idiom can decrease compile time, but Is there any
        > good practice/idiom to decrease link time?
        >
        > any reference or any idea is appreciated
        >
        > thanks
        >[/color]

        This is a bit platform dependent. But you could use dll/shared libraries to
        a greater extent
        so linking of the "executable " can be minimized to just the externals
        provided by the libraries.
        I've not noticed a problem with links on Windows or Red Hat Linux, maybe if
        you use HP or
        IBM you might have some long link jobs.

        Perhaps you could use static functions where appropriate, but I suspect this
        like trying to lose
        weight by cutting your fingernails.

        dave


        Comment

        • Mike Wahler

          #5
          Re: how to decrease link time


          "red floyd" <no.spam@here.d ude> wrote in message
          news:%0Hwf.1901 5$UF3.14558@new ssvr25.news.pro digy.net...[color=blue]
          > baibaichen wrote:[color=green]
          >> i know that pImpl idiom can decrease compile time, but Is there any
          >> good practice/idiom to decrease link time?
          >>
          >> any reference or any idea is appreciated
          >>[/color]
          >
          > Link time is so minimal compared to compile time and totally negligible
          > compared to run time.[/color]

          <OT>

          I've found that this depends upon the project. I've
          worked on projects which used several large third-party
          libraries. Link time was considerably longer than
          compile time. This ratio was made even larger because
          I often would suppy the compiler with several source files
          at a time, which meant the compiler was only invoked once.

          As always, YMMV.

          </OT>

          -Mike


          Comment

          • Rolf Magnus

            #6
            Re: how to decrease link time

            red floyd wrote:
            [color=blue]
            > baibaichen wrote:[color=green]
            >> i know that pImpl idiom can decrease compile time, but Is there any
            >> good practice/idiom to decrease link time?
            >>
            >> any reference or any idea is appreciated
            >>[/color]
            >
            > Link time is so minimal compared to compile time and totally negligible
            > compared to run time.
            >
            > Design instead for maintainability . pImpl provides support for this, by
            > divorcing implementation and interface. The compile time benefits (if
            > any) are just icing on the cake.[/color]

            I have a different view on that. I hate writing code for an hour and then
            searching for the erros for several hours because I did so many changes at
            once. So I usually rather change my code in many small steps.
            Each time, I have to compile the program to try whether it's ok. If compile
            time is long, it slows me down considerably.

            Comment

            • Dietmar Kuehl

              #7
              Re: how to decrease link time

              baibaichen wrote:[color=blue]
              > any reference or any idea is appreciated[/color]

              In general, reducing the dependencies between modules improves both
              compile and link time, sometimes removing the need to compile and/or
              link certain parts of the application altogether (the latter is the
              case when using shared libraries/DLLs where only this objects needs
              to be linked). The pimpl idiom is just one approach to reduce
              dependencies, there are several others. John Lakos' "Large Scale C++"
              (Addison-Wesley) presents several decoupling techniques.
              --
              <mailto:dietmar _kuehl@yahoo.co m> <http://www.dietmar-kuehl.de/>
              <http://www.eai-systems.com> - Efficient Artificial Intelligence

              Comment

              • JustBoo

                #8
                Re: how to decrease link time

                On Tue, 10 Jan 2006 13:38:03 +0100, Rolf Magnus <ramagnus@t-online.de>
                wrote:[color=blue]
                >I have a different view on that. I hate writing code for an hour and then
                >searching for the erros for several hours because I did so many changes at
                >once. So I usually rather change my code in many small steps.
                >Each time, I have to compile the program to try whether it's ok. If compile
                >time is long, it slows me down considerably.[/color]

                This follows the Refactoring Methodologies outlined in Martin Fowlers
                book. Hey, they have a webpage:

                Introduction to the technique of refactoring and online catalog of refactorings


                Good Stuff.

                Comment

                • Thomas Maier-Komor

                  #9
                  Re: how to decrease link time

                  baibaichen wrote:[color=blue]
                  > i know that pImpl idiom can decrease compile time, but Is there any
                  > good practice/idiom to decrease link time?
                  >
                  > any reference or any idea is appreciated
                  >
                  > thanks
                  >[/color]

                  if you are using the GNU toolchain, you might take an alternative
                  compiler/linker combination into consideration. The GNU linker is known
                  to be slooooooow...

                  Tom

                  Comment

                  • red floyd

                    #10
                    Re: how to decrease link time

                    Rolf Magnus wrote:[color=blue]
                    > red floyd wrote:[color=green]
                    >>Design instead for maintainability . pImpl provides support for this, by
                    >>divorcing implementation and interface. The compile time benefits (if
                    >>any) are just icing on the cake.[/color]
                    >
                    >
                    > I have a different view on that. I hate writing code for an hour and then
                    > searching for the erros for several hours because I did so many changes at
                    > once. So I usually rather change my code in many small steps.
                    > Each time, I have to compile the program to try whether it's ok. If compile
                    > time is long, it slows me down considerably.
                    >[/color]

                    And two years down the line, when you have to spend three days searching
                    for the bug your clever link optimization caused, or you're dealing with
                    a portability issue (you need to port to a different OS) caused by your
                    clever link optimization, you'll have wasted much more time.

                    Not to mention that to fix said bug, you'll probably have to refactor
                    etc... Design for mainainability.

                    Comment

                    • baibaichen

                      #11
                      Re: how to decrease link time

                      imagine that I am sitting at my desk fixing bugs all day long. When I
                      make a change and build, how many files are going to compile? 3? 10?
                      100? My guess is that over a whole day, each build will compile maybe
                      five files on average. Only rarely will I make a change to some header
                      file that causes more than 100 files to be recompiled. How long does it
                      take five files to compile? On my laptop, which is over a year old,
                      five files will compile in less than 30 seconds, and often in less than
                      10 seconds. Now consider link times: on my laptop, it takes about 12
                      minutes for DVDit to link, even if only one source file was changed.

                      Even if I were compiling 50 files, that's still less than five minutes,
                      and often less than two minutes. I wonder how much you could actually
                      reduce that by using relative paths.

                      Comment

                      • Alf P. Steinbach

                        #12
                        Re: how to decrease link time

                        * baibaichen:[color=blue]
                        > i know that pImpl idiom can decrease compile time, but Is there any
                        > good practice/idiom to decrease link time?[/color]

                        Yes, the same as in general programming: divide and conquer.

                        If you're linking some hundreds of object files you have packaging problem:
                        repackage in smaller libraries (this may require some redesign; packaging
                        can affect design and vice versa). Use the appropriate options and/or tools
                        to optimize your libraries for fast access. E.g., under *nix, run 'ranlib'.

                        If you're linking some hundreds of libraries you also have a packaging
                        problem: repackage in smaller executables and dynamic libraries (this may
                        require some redesign; packaging can affect design and vice versa).

                        Of course this has only tangentially to do with current C++ as a language.

                        But, to the degree usage of the language is affected and hindered by tool
                        usage I think at least this kind of high level advice is on-topic. However,
                        be aware that concrete tool usage issues are rarely or not ever on-topic in
                        this group. This group is concerned with the C++ _language_.

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

                        • Stephan Brönnimann

                          #13
                          Re: how to decrease link time

                          Are you using libraries (shared?) or do you just link all object files?
                          Just a wild guess: I suspect the system starts trashing when you link.
                          Monitor the disk I/O, memory and swap space usage.

                          regards, Stephan

                          Comment

                          Working...