Author Topic: Optimizing Makefilegenerator  (Read 13308 times)

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Optimizing Makefilegenerator
« Reply #15 on: November 24, 2005, 12:00:09 pm »
Well, DoAppendCompilerOptions does call MacrosManager::ReplaceEnvVars, which calls MacrosManager::ReplaceMacros, which looks like it might take a lot of time. String operations tend to be more expensive that one would think.
That, and we don't yet know his system specs of course.

Offline mandrav

  • Project Leader
  • Administrator
  • Lives here!
  • *****
  • Posts: 4291
    • Code::Blocks IDE
Re: Optimizing Makefilegenerator
« Reply #16 on: November 24, 2005, 01:11:53 pm »
Still...
40+ seconds?!?  :shock:
Be patient!
This bug will be fixed soon...

Offline Urxae

  • Regular
  • ***
  • Posts: 376
Re: Optimizing Makefilegenerator
« Reply #17 on: November 24, 2005, 02:41:58 pm »
Well, I have noticed on my computer (750 MHz laptop, 256 MB RAM) that it can take quite some time before C::B starts the first g++ when compiling itself. I'm not sure if it differs if more files need recompiling, and I don't feel like trying: a full rebuild usually takes around an hour on this machine.
Yes I know, I need a better machine :(.

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Optimizing Makefilegenerator
« Reply #18 on: November 24, 2005, 05:24:51 pm »
Yiannis:

I got an old Athlon 1800+ running at 1.5 GHz. My machine isn't very fast. And YES, I *did* disable the stability tweak.

Second: The measurement used by wxStopWatch isn't very accurate. This, and taking into account that the times are
calculated in VERY TIGHT loops and then added. CPUs don't use subatomic clocks for
time measurement, and noticing that each call to this routine may take about 10ms, i'm sure there are cumulative rounding errors.
(The full-rebuild version takes about 10 seconds to calculate, and the SDK test takes about 5 seconds. So I'd say the reported times are 4X the real time ellapsed.)

However, we should pay attention to the RELATIVE times. So call them milliseconds, or clock ticks, the point is that some parts of the routine take much longer than they should.
Remember you told me that the string replacing parts weren't very CPU-consuming? Well, the reported time was less than 5% the total times for the calculation.

Also take into account the percentages. The numbers for the SDK calculation are proportional to the numbers for the full-rebuild calculation. So the numbers do make sense.

Edit: here they are, the normalized times.
Code: [Select]
Timer  1: 0
Timer  2: 5046 ms (40.16%)
Timer  3: 1312 ms (10.44%)
Timer  4: 0 ms
Timer  5: 1189 ms (9.46%)
Timer  6: 0 ms
Timer  7: 3142 ms (25.01%)
Timer  8: 15 ms   (0.12%)
Timer  9: 0 ms
Timer 10: 1577 ms (12.55%)
Timer 11: 16 ms   (0.13%)
Timer 12: 0 ms
Timer 13: 218 ms  (1.73%)
Timer 14: 48 ms   (0.38%)
Timer 15: 0 ms

Total "time": 12563

All Targets
---------------
Timer  1: 0 ms
Timer  2: 17007 ms (41.61%)
Timer  3: 3243 ms  (7.93%)
Timer  4: 0 ms
Timer  5: 3733 ms  (9.13%)
Timer  6: 16 ms    (0.04%)
Timer  7: 10747 ms (26.29%)
Timer  8: 78 ms    (0.19%)
Timer  9: 0 ms
Timer 10: 5030 ms  (12.30%)
Timer 11: 32 ms    (0.08%)
Timer 12: 0 ms
Timer 13: 894 ms   (2.19%)
Timer 14: 110 ms   (0.27%)
Timer 15: 0 ms

Total "time": 40874

So, for both cases, timer2 gets 41%, timer7 gets 25% and timer10 gets 12%.

Now, how are we gonna solve this?
We could, for example, move some of the calculations to outside the loop (that calls the function in question), because they're dependent on the target, not on the filename. I'd appreciate if you gave more details on what strings exactly you're generating. All those replaced macros get me dizzy.
« Last Edit: November 24, 2005, 05:43:42 pm by rickg22 »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Optimizing Makefilegenerator
« Reply #19 on: November 25, 2005, 08:13:20 am »
Good news people! Yiannis sent me a prototype for an optimized version, and it's got rid of almost all of the bottleneck!

I measured the full-rebuild calculation times, with and without patch.

Without patch: 19.16 seconds (with manual stopwatch)
With patch: 01.80 seconds  (with manual stopwatch). This varies on occasions, up to 4 seconds. I'm not sure why.

Now we have only to take care of some minor details and a linking bug, and we're done :)

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Optimizing Makefilegenerator
« Reply #20 on: November 25, 2005, 08:51:13 am »
Sounds good :)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Optimizing Makefilegenerator
« Reply #21 on: November 28, 2005, 07:05:58 am »
More good news, people! I fully revamped the MacrosManager, and this alone reduced the full rebuild calculation time from 13 seconds to 1.7! :shock:

For those curious, makefile generation is now practically *instant*. Takess less than a second now!

(Yes, I rebuilt codeblocks, compared makefile generation and everything works exactly the same. Ceniza compared, too!)

I can't wait till Yiannis uploads his part of the patch :D