Repository navigation
Run callable recipe generators in process - #153
akritkbehera wants to merge 1 commit into
Conversation
|
Nice — the opt-in is clean and it's inert for everyone who doesn't use it. Can you port this to optimisation branch which I am about to merge with main> Three issues:
The exception is discarded — not logged, not chained. The whole case for this change is 97.6 s → 23.5 s, and as written a callable that breaks on one platform or one package silently reverts to the subprocess path. The build still succeeds, so nobody finds out until somebody re-profiles; the speedup you measured can quietly disappear. It also means that if the fallback command then fails, getoutput → dieOnError reports the command's error and the callable's actual bug is gone. Two lines keep it: and raise ... from exc if you'd rather re-raise with the chain intact. Worth noting too that an in-process callable which fails after side effects leaves them in place, and the command then runs on top — a subprocess couldn't do that.
Minor, non-blocking: self.generate().strip() assumes a string; a callable returning None raises AttributeError, which the except then turns into a silent fallback. An explicit check naming the package would fail more usefully. A generator dict with neither generate nor command dies with a bare KeyError: 'command'. Naming the package would help whoever wrote it. obj["command"] if self.generate is None else obj.get("command") reads awkwardly for what it does. |
Summary
Allow generated recipes to provide a Python generate callable. Bits runs the callable in the current process and passes its text output through the existing recipe parser. This avoids starting a Python subprocess for each recipe that opts in.
Generators that provide only command continue to work as before. If a callable raises and a fallback command is available, bits runs the command to preserve its diagnostics and exit behavior.
Performance
Performance
A CMSSW dependency resolution profile spent 22.35 seconds out of approximately 25 seconds in generated recipe subprocesses, about 89% of that phase.
With the companion recipe changes that opt into callables, one local bits build cmssw-tools --dry-run comparison measured:
That run was 4.15× as fast, a 76% reduction in wall time. These are local measurements.