0

I have an SConscript that constructs targets using the m4 and sed utilities included with Cygwin.

Overall, the build takes about 42 seconds to construct 16 targets from 8 sources, but the same build only takes Make about 4 seconds! That's a tenfold time difference for what is a fairly trivial build! I know SCons has to run through the Python interpreter, so of course it won't be as fast as a native executable like Make, but still, I have to assume that with such a basic build as mine, I must be doing something really silly to be seeing such a massive time difference. Any ideas or suggestions?

Based on some suggestions in the comments, I have replaced my custom m4 builder with SCons in-built one, and I have gotten rid of the sed one altogether just to reduce the number of potential causes, and the total build time is now down to 22 seconds. You can now see the entirety of my code below:

SConstruct:

env = DefaultEnvironment(tools=['m4'])
env['ENV']['PATH'] = ['C:/cygwin/bin']
SConscript('sources/SConscript', exports = 'env', variant_dir='build', duplicate = 0,) 

sources\SConscript:

from ntpath import basename # Gets a file's basename from it's pathname.
Import('env')
M4FLAGS = '-DVV_SUBDERIVATIVE_NAME=5777C -DM4_USER_MODE_CONFIGURATION=true'
for file in Glob("*.xdm"):
    env.M4(target=basename(str(file))+'.orig', source=file, M4FLAGS=M4FLAGS)
LongTP5
  • 417
  • 3
  • 11
  • How long does an "update" take (everything is built and no changes have been made in between)? Where do the `m4` and `sed` builders come from? The default M4 builder as provided out-of-the-box should be named "M4". You can try to call `scons --debug=time`, this should give you a better idea about where all the time is spent. Please post the results here (together with the used code of your Builders/Emitters if required)... – dirkbaechle Mar 06 '19 at 09:35
  • Might be related: https://stackoverflow.com/questions/35973789/need-help-debugging-slow-scons-runtime and https://stackoverflow.com/questions/50030787/scons-super-slow-startup-in-windows – dirkbaechle Mar 06 '19 at 09:44
  • The _m4_ and _sed_ builders are my own. I have updated my question with more information. – LongTP5 Mar 07 '19 at 02:31
  • To answer your other questions @dirkbaechle, for a rebuild, `Total build time: 0.356000 seconds.` For a clean build, `Total build time: 25.666000 seconds.` The majority of the time does seem to be taken by my builders; about 1.5 seconds each. I tried deleting the _sconsign_ file as suggested in one of the links you shared, but I can see no appreciable difference. If you can help me to get the in-built m4 builder working, I will try to see if that has any impact on the time. – LongTP5 Mar 07 '19 at 02:55
  • It looks like you are working under Windows/cygwin? You have to make sure that your "m4" executable can be found in the `env` that you're trying to use. See #1 of our [most-frequently asked FAQ](https://scons.org/faq.html). Also make sure that for your `env` the `PLATFORM` variable isn't set to "WINDOWS". Else *SCons* thinks its running under Windows and doesn't load the `m4` tool as default. You'd have to explicitly request it via the `tools=['m4']` keyword then, I guess. – dirkbaechle Mar 07 '19 at 09:00
  • Please paste your builders source. – bdbaddog Mar 07 '19 at 15:49
  • _Damn time zones have me working only when you guys are asleep it seems._ OK. I have updated my build to use the in-built _m4_ builder instead of my own, and gotten rid of the _sed_ builder altogether. I have updated my question to provide _all_ of my code now. My `env['PLATFORM']` is set to `win32`. I'm not sure what else it should be. I didn't think it would matter, seeing as I am explicitly setting `env['ENV']['PATH']`. – LongTP5 Mar 08 '19 at 01:30
  • Did you check antivirus? On windows I have had several antivirus software cause SCons to run very slow. Could you try completely disabling any antivirus, or test on a native linux system instead of cygwin? – dmoody256 Mar 12 '19 at 20:12
  • OK. I had IT disable my antivirus today to see if it makes a difference. Unfortunately it made no difference, in fact I compared a couple of clean builds both before and after the antivirus was switched back on, and the second build was actually about 2 seconds _faster_, so I think it's safe to say that it's not the antivirus. One observation that may be of interest is the inconsistency of the time to build. As my original question suggests, it sometimes takes up to 42 seconds, but today I saw it take as little as 14.5. Though it's always consistently slower than _Make_. – LongTP5 Mar 13 '19 at 08:45

0 Answers0