riidefi / mkw

Decompilation of Mario Kart Wii
302 stars 32 forks source link

Remove multiprocessing #57

Closed wait-wtf closed 1 year ago

wait-wtf commented 3 years ago

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).

mkst commented 3 years ago

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)

riptl commented 3 years ago

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

riptl commented 2 years ago

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

em-eight commented 1 year ago

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

riptl commented 1 year ago

Thanks @em-eight 🎉