GeezerVison is showing github.com — make altinstall for PGO is not parallel-safe · Issue #93584 · python/cpython
make altinstall for PGO is not parallel-safe #93584DescriptionBug report
setup.py has a helper method add_multiarch_paths. The method creates a temporary file build/lib.{platform}/multiarch and unlinks it at the end of the function call. This is not parallel-safe.
PGO builds of Python use $(MAKE), so called recursive make. Recursive makes are considered harmful because the main make process has no understanding what the child make process is doing. With heavy parallel makes this can cause race conditions.
The combination of unsafe add_multiarch_paths(), recursive make and loooots of CPU cores can lead to build issues like #84461 (comment).
Possible workarounds
- Rewrite our Makefile to not use
$(MAKE)
- Move
CC -print-multiarch and dpkg-architecture ... -qDEB_HOST_MULTIARCH calls to configure.ac
- Fix
_bootsubprocess.check_output() and add_multiarch_paths() to use a more safe tmp file
Option (3) is the simplest approach. Even tmpfile = os.path.join(self.build_temp, f'multiarch-{os.getpid()}') would be good enough to avoid file conflicts in parallel builds. Activitytiran commented on Jun 7, 2022 My PR solved the race condition in add_multiarch_paths() but revealed another race condition later.
@pablogsal 's problem is caused by the fact that PGO builds use recursive make. The sharedmods target and the profile-opt target run ./python setup.py build at the same time. setup.py is not designed to be parallel-safe. emmatyping commented on Jun 7, 2022 Weird, I never hit a compilation failure after 2 hours of trying on my 32 core machine, maybe this is an edge case you can only hit with the macOS scheduler. tiran commented on Jun 7, 2022 Did you create a build with configure --enable-optimizations? The issue only occurs with PGO builds. emmatyping commented on Jun 7, 2022 Yeah, I was running a script in a loop using the steps from Pablo's reproducer here: #84461 (comment)
After 2 hours it still hadn't failed pablogsal commented on Jun 7, 2022
Yeah, I was running a script in a loop using the steps from Pablo's reproducer here: #84461 (comment)
After 2 hours it still hadn't failed
That's odd. I have been able to reproduce in at least 3 systems, including Linux with arch Linux and RHEL7 tiran commented on Jun 8, 2022 In comment #93589 (comment) @nascheme suggested to rename some of the targets to make the intention more clear. I like the idea, but I don't want to mix improvements with a release blocker fix. changed the title [-]setup.py add_multiarch_paths() is not parallel-safe with recursive make[/-] [+]make altinstall for PGO is not parallel-save[/+] on Jun 8, 2022changed the title [-]make altinstall for PGO is not parallel-save[/-] [+]make altinstall for PGO is not parallel-safe[/+] on Jun 15, 2022tiran commented on Jun 15, 2022 Reacted by Pablo Galindo Salgado
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|