python / python/cpython

Parallelize deepfreeze.py

Open
#94,727 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.13 build type-feature
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Feature or enhancement

I propose to parallelize deepfreezing to speed up compile time for core devs.

Pitch

deepfreezing / deepfreeze.py is a choke point for building CPython. Deepfreezing happens very late in the build process and takes considerable amount of time, especially for pydebug builds. Deepfreezing is a single process and does not benefit from multiple cores. Every build that touches a core file will result in re-freezing. On my system and with ccache populates, make spends between 60 to 75% time just in deepfreeze.py for debug builds. For regular builds it's about 25-30% of total build time.

$ ./configure -C --with-pydebug
$ make clean
$ time make

real    0m9,339s
user    0m13,630s
sys     0m2,657s
$ rm Python/deepfreeze/deepfreeze.c
$ time make Python/deepfreeze/deepfreeze.c

real    0m7,267s
user    0m7,033s
sys     0m0,204s

The process can be parallelized. One possible solution is to split the work. For each input module create a make rule that outputs an inc file, e.g. Python/deepfreeze/"importlib._bootstrap.inc. An another rules creates deepfreeze.c with #include "importlib._bootstrap.inc, ... This keeps all code in one object file.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Python/deepfreeze/deepfreeze.py and the build commands shown in the issue, then trace how Python/deepfreeze/deepfreeze.c is generated. Evaluate the proposed per-input .inc outputs and build rules. Done means deepfreezing can use multiple cores while producing the required deepfreeze.c output and preserving the current build flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.