mkw icon indicating copy to clipboard operation
mkw copied to clipboard

Remove multiprocessing

Open wait-wtf opened this issue 3 years ago • 3 comments

The build system currently runs compile jobs in parallel to decrease compile time. This achieved using the multiprocessing library. The multiprocessing library spawns additional instances of the Python interpreter that run independently.

This approach is quite fast, but it causes problems with stdout buffering and early termination: Ctrl+C signals and build errors are not handled properly. Instead of terminating, the build workers will continue to compile their whole job queue away. This makes it hard to see where an error occurs.

Modern Python has a nicer way to deal with this. The asyncio/subprocess library allows dispatching multiple subprocesses (compiler invocations) from the same interpreter instance. Stdout is handled asynchronously through an event loop.

So, let's either look into asyncio's subprocess functionalities, or consider using a full-fledged Python build system like SCons. GNU Make has been suggested* in the past but has been rejected due to concerns with Windows compatibility and maintainability (Makefiles are unforgiving and opaque at times).

wait-wtf avatar Jul 24 '21 12:07 wait-wtf

The papermario decompers use ninja as their build tool (see https://github.com/pmret/papermario/blob/master/tools/build/configure.py), seems to work well for them (although the N64 decomps are dealing with more than just an executable)

mkst avatar Aug 07 '21 12:08 mkst

Nice, thanks for sharing. I didn't know Ninja integrates with Python that well. Worth considering for sure. cc @riidefi

riptl avatar Aug 07 '21 14:08 riptl

mkw-sp also uses ninja – we should switch too.

riptl avatar Mar 23 '22 17:03 riptl

@riidefi now that we use ninja, this can be closed

em-eight avatar Dec 13 '22 14:12 em-eight

Thanks @em-eight 🎉

riptl avatar Jan 18 '23 15:01 riptl