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

GH-99554: Pack location tables more effectively #99556

Merged
merged 7 commits into from Dec 22, 2022

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Nov 17, 2022

This shrinks the size of .pyc files by about 10%. It also shrinks the memory footprint of all code objects in the process.

@brandtbucher brandtbucher added performance Performance or resource usage interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Nov 17, 2022
@brandtbucher brandtbucher requested a review from markshannon as a code owner Nov 17, 2022
@brandtbucher brandtbucher self-assigned this Nov 17, 2022
@brandtbucher brandtbucher requested a review from iritkatriel as a code owner Nov 17, 2022
Python/compile.c Outdated
static inline bool
same_location(location a, location b)
{
if (a.lineno < 0 && b.lineno < 0) {
Copy link
Member

@iritkatriel iritkatriel Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d check also that they are the same value in case we will want to distinguish between ‘no location’ and ‘unknown location’ or something like that.

(I’m assuming you don’t rely on the full equality check because we’re inconsistent about what the other 3 values are).

Copy link
Member

@markshannon markshannon Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an "unknown location" ever exist? That sounds like a compiler bug.

Copy link
Member

@iritkatriel iritkatriel Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking of cases where we just want to take the location of the previous instruction. Currently we just say "NO_LOCATION", but would we ever want to distinguish between this case and the case where there truly is no location (because the instructions are fake)? I don't know, but we might not want to rule it out.

Copy link
Member Author

@brandtbucher brandtbucher Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I’m assuming you don’t rely on the full equality check because we’re inconsistent about what the other 3 values are).

Actually, it appears that we can remove this special case entirely. Just using the full equality check results in the exact same PYC sizes for the entire stdlib.

@netlify
Copy link

netlify bot commented Dec 15, 2022

Deploy Preview for python-cpython-preview ready!

Name Link
🔨 Latest commit be7eb0a
🔍 Latest deploy log https://app.netlify.com/sites/python-cpython-preview/deploys/639b60d4868560000855722c
😎 Deploy Preview https://deploy-preview-99556--python-cpython-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@brandtbucher brandtbucher merged commit 3c033a2 into python:main Dec 22, 2022
16 checks passed
@bedevere-bot
Copy link

bedevere-bot commented Dec 22, 2022

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x SLES 3.x has failed when building commit 3c033a2.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/540/builds/4270) and take a look at the build logs.
  4. Check if the failure is related to this commit (3c033a2) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/540/builds/4270

Summary of the results of the build (if available):

== Tests result: ENV CHANGED ==

414 tests OK.

10 slowest tests:

  • test_concurrent_futures: 2 min 42 sec
  • test_tools: 2 min 41 sec
  • test_multiprocessing_spawn: 2 min 29 sec
  • test_asyncio: 1 min 49 sec
  • test_multiprocessing_forkserver: 1 min 20 sec
  • test_multiprocessing_fork: 1 min 19 sec
  • test_subprocess: 1 min 15 sec
  • test_signal: 1 min 9 sec
  • test_capi: 1 min 2 sec
  • test_venv: 58.4 sec

1 test altered the execution environment:
test_asyncio

18 tests skipped:
test_check_c_globals test_devpoll test_ioctl test_kqueue
test_launcher test_msilib test_nis test_peg_generator
test_perf_profiler test_startfile test_tix test_tkinter test_ttk
test_winconsoleio test_winreg test_winsound test_wmi
test_zipfile64

Total duration: 6 min 4 sec

Click to see traceback logs
remote: Enumerating objects: 20, done.        
remote: Counting objects:   5% (1/20)        
remote: Counting objects:  10% (2/20)        
remote: Counting objects:  15% (3/20)        
remote: Counting objects:  20% (4/20)        
remote: Counting objects:  25% (5/20)        
remote: Counting objects:  30% (6/20)        
remote: Counting objects:  35% (7/20)        
remote: Counting objects:  40% (8/20)        
remote: Counting objects:  45% (9/20)        
remote: Counting objects:  50% (10/20)        
remote: Counting objects:  55% (11/20)        
remote: Counting objects:  60% (12/20)        
remote: Counting objects:  65% (13/20)        
remote: Counting objects:  70% (14/20)        
remote: Counting objects:  75% (15/20)        
remote: Counting objects:  80% (16/20)        
remote: Counting objects:  85% (17/20)        
remote: Counting objects:  90% (18/20)        
remote: Counting objects:  95% (19/20)        
remote: Counting objects: 100% (20/20)        
remote: Counting objects: 100% (20/20), done.        
remote: Compressing objects:  12% (1/8)        
remote: Compressing objects:  25% (2/8)        
remote: Compressing objects:  37% (3/8)        
remote: Compressing objects:  50% (4/8)        
remote: Compressing objects:  62% (5/8)        
remote: Compressing objects:  75% (6/8)        
remote: Compressing objects:  87% (7/8)        
remote: Compressing objects: 100% (8/8)        
remote: Compressing objects: 100% (8/8), done.        
remote: Total 11 (delta 9), reused 4 (delta 3), pack-reused 0        
From https://github.com/python/cpython
 * branch                  main       -> FETCH_HEAD
Note: switching to '3c033a2e6fbde56f904aeca138141be6564341cf'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 3c033a2e6f GH-99554: Pack location tables more effectively (GH-99556)
Switched to and reset branch 'main'

make: *** [Makefile:1892: buildbottest] Error 3

static inline bool
same_location(location a, location b)
{
return a.lineno == b.lineno &&
Copy link
Member

@gvanrossum gvanrossum Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to git diff you have a trailing space here. Surprised CI didn't catch it?

Copy link
Member Author

@brandtbucher brandtbucher Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, nice catch! I'll fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) performance Performance or resource usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants