Repository navigation
Logically merge cell and locals array. They are already contiguous in memory #87859
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = None
created_at = <Date 2021-04-01.11:33:50.457>
labels = ['interpreter-core', 'performance']
title = 'Logically merge cell and locals array. They are already contiguous in memory'
updated_at = <Date 2021-07-21.18:07:49.033>
user = 'https://github.com/markshannon'bugs.python.org fields:
activity = <Date 2021-07-21.18:07:49.033>
actor = 'gvanrossum'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Interpreter Core']
creation = <Date 2021-04-01.11:33:50.457>
creator = 'Mark.Shannon'
dependencies = []
files = []
hgrepos = []
issue_num = 43693
keywords = ['patch']
message_count = 32.0
messages = ['389974', '390069', '390247', '390253', '394455', '394556', '395014', '395059', '395097', '395098', '395102', '395105', '395137', '395273', '395294', '395297', '395317', '395318', '395319', '395321', '395326', '395329', '395331', '395332', '395338', '395365', '395448', '395899', '396015', '396288', '396433', '397956']
nosy_count = 8.0
nosy_names = ['gvanrossum', 'rhettinger', 'ncoghlan', 'Mark.Shannon', 'eric.snow', 'serhiy.storchaka', 'Guido.van.Rossum', 'pablogsal']
pr_nums = ['25152', '26216', '26258', '26364', '26375', '26388', '26396', '26530', '26577', '26587', '26588', '26597', '26609', '26626', '26749', '26839']
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'open'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue43693'
versions = []Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usage
Activity
markshannon commentedon Apr 1, 2021
In the interpreter and compiler, the "fast" locals array and cells array are treated separately. By merging them in the compiler, the interpreter can be simplified a bit.
rhettinger commentedon Apr 2, 2021
This doesn't look simpler to me. We will forever lose mental clock cycles disentangling the locals and cells. So, I don't think they should be commingled.
gvanrossum commentedon Apr 5, 2021
To me it looks simpler though. The locals and cells are already stored in a single array, f_localsplus (which also contains the evaluation stack). There are various complications in ceval.c to translate cell indexes to indexes in this array (ein particular the extra local variable 'freevars', which weighs down the stack frame).
Making the interpreter simpler by moving things to the compiler also makes it easier for the C compiler to optimize the code of the interpreter better.
serhiy-storchaka commentedon Apr 5, 2021
LGTM.
markshannon commentedon May 26, 2021
New changeset 6cc800d by Eric Snow in branch 'main':
bpo-43693: Clean up the PyCodeObject fields. (GH-26364)
6cc800d
ericsnowcurrently commentedon May 27, 2021
New changeset 9f494d4 by Eric Snow in branch 'main':
bpo-43693: Add _PyCode_New(). (gh-26375)
9f494d4
ericsnowcurrently commentedon Jun 3, 2021
New changeset 2c1e258 by Eric Snow in branch 'main':
bpo-43693: Add new internal code objects fields: co_fastlocalnames and co_fastlocalkinds. (gh-26388)
2c1e258
ericsnowcurrently commentedon Jun 4, 2021
New changeset b2bf2bc by Mark Shannon in branch 'main':
bpo-43693: Compute deref offsets in compiler (gh-25152)
b2bf2bc
pablogsal commentedon Jun 4, 2021
Unfortunately, commit 2c1e258 has broken all the refleak buildbots. Example failure:
BISECTION:
c1e2583fdc4db6b43d163239ea42b0e8394171f is the first bad commit
commit 2c1e258
Author: Eric Snow <ericsnowcurrently@gmail.com>
Date: Thu Jun 3 10:28:27 2021 -0600
https://buildbot.python.org/all/#/builders/384/builds/50/steps/5/logs/stdio
As this is affecting all test, I am proceeding with a revert of commit 2c1e258 directly to not mask other issues.
18 remaining items
ericsnowcurrently commentedon Jun 15, 2021
New changeset ac38a9f by Eric Snow in branch 'main':
bpo-43693: Eliminate unused "fast locals". (gh-26587)
ac38a9f
ericsnowcurrently commentedon Jun 17, 2021
FWIW, I've wrapped up the key parts that I wanted to get done here
(co_localplusnames/kinds, MAKE_CELL, eliminate unused fast local
for arg cells). I'm leaving this open for now as there are a few
things I didn't do that seem part of the original intention of this
issue:
(rather than only interleaving arg cells)
them after the fact during the assembler step
(this will allow us to remove a decent amount of code)
(this should allow us to make _PyEval_MakeFrameVector() simpler
and a bit more efficient)
gvanrossum commentedon Jun 21, 2021
New changeset 355f5dd by Guido van Rossum in branch 'main':
bpo-43693: Turn localspluskinds into an object (GH-26749)
355f5dd
gvanrossum commentedon Jun 23, 2021
New changeset 769d7d0 by Guido van Rossum in branch 'main':
bpo-43693 Get rid of CO_NOFREE -- it's unused (GH-26839)
769d7d0
gvanrossum commentedon Jul 21, 2021
Another task seems to have appeared, Nick Coghlan would like the typedef to be renamed to PyLocal_VarKind, and the getter/setter similarly.
markshannon commentedon May 2, 2022
I don't think there is anything left to do here, so closing.
gh-87859: Track Code Object Local Kinds For Arguments (gh-132980)