March Update

Following the last burst of updates, it might appear that I’ve taken a break lately.  Unfortunately, I haven’t gotten a break- I’ve been trying to track down some ugly bugs that I found in the roughing code while helping a friend machine a bunch of parts.  It took a couple of weeks to find the root of the problem- it turns out that using a “Machine Stock +” value of 0 can lead to some really incorrect paths when check surfaces are used.  This might be an edge case but I really had no idea what combination of settings caused it until yesterday.  Now that I have it narrowed down I should be able to fix it pretty quickly.

 

As a break from that problem, today I’ve been fixing a couple of small user bugs and trying to reduce the overall memory usage a bit now that I have been getting more and more users with > 1 million triangle models lately.  This is not what I wanted to do so close to a release but the trend lately is large files and I don’t want to lose those users to other programs.  The changes I’m making require a complete recompile of the program since these are core data structures.  Each build takes about 20 minutes.  As you can imagine, errors are frustrating when they mean I have to wait another 20 minutes to rebuild.  Hopefully this will have some payoff.

6 Comments

  1. “As you can imagine, errors are frustrating when they mean I have to wait another 20 minutes to rebuild.”

    Ah, kids these days. :) I learned Fortran while a senior in high school–I was alpha-tester for a self-paced book written by a friend of my calculus teacher. I punched cards on a surplus IBM cardpunch and on Friday my teacher took the card deck for that week down to the mainframe at the state capitol to run. Frustration is waiting a week for the printout of the program, which on bad weeks read “Syntax error in line 240″…

    Randy

  2. 20 minutes? Unless you have millions of lines of code, you’re doing it wrong. :) Have you looked into using precompiled headers? In 2004, I had a complete hockey game compiling in under 3 minutes using custom PCH files. If you’d like a hand setting it up, I can help. It’s quite easy. Be aware that “automatic” mode isn’t really automatic, and is typically used wrong.

    Another option is renaming a bunch of related files from .cpp to .inc, and then making a single .cpp file that includes them. Since related files use the similar includes, you only process those once, and finding/parsing them is generally the bulk of the time spent compiling. I’ve found doing this in units of 10 to 20 files can make your “incremental” compile time about 5% slower, but the “full rebuild” time about 10x faster.

    Jason

  3. Of course I’m doing it wrong :) . I tried to setup PCH up a couple years ago and I had a bunch of trouble. At the time the project was small so it didn’t matter anyway. Now that it has grown, I think the benefit would be significant. My goal was to get V3 done and do this in V4 when I can start with a clean branch of code and make the change.

    I never thought about combining a bunch of files into one translation unit. That might be a good alternative for some areas of the program.

    -Robert

  4. Manual PCH files are almost startingly simple to work with.

    - Write a .h file that #includes the largest and most commonly used header files. This is the header that will be precompiled.

    - Write a .cpp that simply includes that master .h file. This is used to generate the PCH file.

    - Select all your .cpp files, and in the settings, set “use pre-compiled header”, and specify the name of your master header file.

    - Select the single .cpp that just includes the master header, and in the settings, set “generate pre-compiled header” and specify the name of the master header.

    Then you just add #include “MasterHeader.h” to the top of all your source files, and that’s it. If a file is small enough, you can turn off the PCH usage for that file. Be aware that you need to put the PCH file first, as the compiler will skip everything up to the point that it finds that #include “MasterFile.h” line, assuming that it’s all in the PCH file.

    Depending on the number of source files you have, this will probably take ten minutes or so.

    Don’t include anything in the PCH file that changes often, if possible – Use it for things like Windows.h, library headers that you use all the time, files that include a lot of other files, and so on.

    The beauty of the PCH files is that they boost full rebuild -and- incremental build times by an order of magnitude. Well worth the effort – I use them for damn near everything. :)

    Jason

  5. Thanks for the outline. I’ll have to give it a try. Is there any additional (or reduced ) benefits for header files that contain a lot of templates?

    -Robert

  6. I don’t use a lot of templates, so I’m not sure how they’ll affect the performance. You’ll still see the benefit of not having to find/parse them multiple times, which is by far the bulk of time spent compiling “normal” code.