Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-45696: Deep-freeze #29118

Merged
merged 46 commits into from Nov 11, 2021
Merged

bpo-45696: Deep-freeze #29118

merged 46 commits into from Nov 11, 2021

Conversation

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Oct 21, 2021

See faster-cpython/ideas#84

This seems to be 10% faster than current main[1], so an improvement over Eric's freeze.

Downside: the data segment grows from 490 KB to 1.3 MB. (We could get ~300 KB back by not including the marshalled-frozen data.)

Another downside, for developers: whenever you touch a source file, _bootstrap_python gets rebuilt, and that triggers a rebuild of all the deep-frozen modules. (See comment below for a possible fix.)

Haven't gotten it working on Windows yet. (The magic is disabled there for now.) I might do that in a separate PR.


[1] Measured on an x86 Mac, with lto-pgo, this shaves 1.5-2 msec off a total run time of around 14 msec. I measured by using the subprocess to run python -c pass 100 times.

https://bugs.python.org/issue45696

Co-authored-by: Inada Naoki <songofacandy@gmail.com>
@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Nov 4, 2021

make -s prints additional noise on stderr. Can you get rid of the warnings from the bootstrap interpreter?

Do you have an example? I don't see any warnings. Unless you mean lines like

Deepfreezing Python/deepfreeze/importlib._bootstrap.c from Lib/importlib/_bootstrap.py

which are explicitly printed by the command in the Makefile (instead of the full command, which is several lines long due to the long and repeated filenames).

Loading

@tiran
Copy link
Member

@tiran tiran commented Nov 4, 2021

The bootstrap interpreter prints two warnings lines when the pybuilddir.txt file does not exist:

$ make clean
$ make -s 
...
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

There is no cleanup target for the new directory. I think clean-retain-profile is the correct place to rm -rf Python/deepfreeze.

Loading

Tools/scripts/deepfreeze.py Outdated Show resolved Hide resolved
Loading
@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Nov 4, 2021

The bootstrap interpreter prints two warnings lines when the pybuilddir.txt file does not exist:

$ make clean
$ make -s 
...
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

I've seen that too, but only in the CI. Maybe it's Linux only? I am at a loss for how to fix it. Should I just set PYTHONHOME=. in the deepfreeze calls?

There is no cleanup target for the new directory. I think clean-retain-profile is the correct place to rm -rf Python/deepfreeze.

There's a README.txt file that we don't want to delete, so I should probably rm -rf Python/deepfreeze/*.[ch]. Or is it a problem that that keeps the empty directory in an out-of-tree build?

Loading

@brettcannon brettcannon removed their request for review Nov 5, 2021
@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Nov 9, 2021

@tiran any idea?

Loading

@tiran
Copy link
Member

@tiran tiran commented Nov 9, 2021

@tiran any idea?

You could try to use the bootstrap interpreter to generate sysconfig and pybuilddir.txt: main...tiran:deepfreeze-bootstrap

In the long run we might be able to replace PYTHON_FOR_REGEN with bootstrap interpreter, too.

Loading

@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Nov 9, 2021

@tiran, Does it look good now? All tests pass. I'll merge origin/main again and re-run the buildbots and then I hope to land this. We'll leave several things to future generations (or at least a later PR):

  • Windows
  • Avoid deep-freezing and rebuilding after every source change
  • Replace PYTHON_FOR_REGEN with $(BOOTSTRAP)

Loading

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 10, 2021

🤖 New build scheduled with the buildbot fleet by @gvanrossum for commit 0c9de73 🤖

If you want to schedule another build, you need to add the "🔨 test-with-buildbots" label again.

Loading

@gvanrossum
Copy link
Member Author

@gvanrossum gvanrossum commented Nov 10, 2021

The AMD64 FreeBSD buildbot is failing (https://buildbot.python.org/all/#/builders/203/builds/314/steps/3/logs/stdio), and AFAICT the cause is that its Make doesn't understand $<. Any suggestions? This part of Makefile.pre.in is generated code, so I could just expand it in the code generator (Tools/scripts/freeze_modules.py), like I had before. Or is there a trick to get this to work on FreeBSD?

Loading

@tiran
Copy link
Member

@tiran tiran commented Nov 10, 2021

I was not aware that bmake has a different syntax for autovars than gmake. I only develop with GNU make. I cannot find a common syntax that works with BSD make and GNU make. You have to go back to the old system.

I'm sorry for the extra work I caused.

Loading

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 10, 2021

🤖 New build scheduled with the buildbot fleet by @gvanrossum for commit 3e88103 🤖

If you want to schedule another build, you need to add the "🔨 test-with-buildbots" label again.

Loading

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 10, 2021

🤖 New build scheduled with the buildbot fleet by @gvanrossum for commit f40d138 🤖

If you want to schedule another build, you need to add the "🔨 test-with-buildbots" label again.

Loading

@gvanrossum gvanrossum merged commit 1cbaa50 into python:main Nov 11, 2021
68 of 69 checks passed
Loading
@gvanrossum gvanrossum deleted the deepfreeze branch Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants