GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove cells_frees duplicate storage from Frame by youknowone · Pull Request #7351 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Mar 4, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Cell/free variable objects were stored in both a separate Box<[PyCellRef]> (cells_frees field) and in the localsplus fastlocals array. Remove the redundant cells_frees field and access cell objects directly through localsplus, eliminating one Box allocation and N clone operations per frame creation.

Summary by CodeRabbit

  • Refactor
    • Optimized VM frame variable storage mechanism by consolidating cell and free variable management for improved internal efficiency and code maintainability.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
Remove cells_frees duplicate storage from Frame
d5514ef
Cell/free variable objects were stored in both a separate
`Box<[PyCellRef]>` (cells_frees field) and in the localsplus
fastlocals array. Remove the redundant cells_frees field and
access cell objects directly through localsplus, eliminating
one Box allocation and N clone operations per frame creation.
@coderabbitai

coderabbitai Bot commented Mar 4, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Frame's cell and free variable storage refactored from a separate cells_frees buffer to inline placement within LocalsPlus.fastlocals array. Frame initialization, accessors, and instruction implementations updated accordingly to use new ExecutingFrame.cell_ref() helper method.

Changes

Cohort / File(s) Summary
Cell/Free Variable Storage Refactoring
crates/vm/src/frame.rs
Removed cells_frees field from Frame struct; cell and free variables now stored directly in LocalsPlus.fastlocals at positions after nlocals. Introduced ExecutingFrame.cell_ref() method for accessing cells. Updated Frame initialization, set_cell_contents(), get_cell_contents(), and Traverse implementation. Updated instruction implementations (DeleteDeref, LoadDeref, StoreDeref, etc.) to use cell_ref() instead of direct cells_frees access.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • LoadClosure as pseudo op #6789: Directly modifies cell/free variable storage in Frame by moving it into fastlocals and removing cells_frees field—core code-level intersection with this PR.
  • Clear frame locals and stack on generator close + Add dir_fd support for rmdir, remove/unlink, scandir #7222: Updates Frame cell storage and access patterns in crates/vm/src/frame.rs with overlapping changes to per-frame cell variable handling.
  • Optimize fast_locals and atomic ordering #7289: Modifies Frame's fastlocals and cell storage paths with related refactoring of cell access mechanisms.

Poem

🐰 A rabbit hops through fastlocals with glee,
Cell variables inline where they belong to be,
No separate buffer to hop around,
Storage unified—efficiency found! 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: removing the redundant cells_frees field from Frame that was duplicating cell/free variable storage.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions
Auto-format: cargo fmt --all
577f474
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Code has been automatically formatted

The code in this PR has been formatted using:

  • cargo fmt --all
    Please pull the latest changes before pushing again:
git pull origin worktree-frame-datastack
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@youknowone
youknowone marked this pull request as ready for review March 5, 2026 00:14
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Mar 5, 2026

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Mar 5, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/vm/src/frame.rs`:
- Around line 743-744: Rename the misleading method clear_stack_and_cells() to
clear_stack() and update its docstring to state it only clears the value stack
(delegating cell/free clearing to clear_locals_and_stack()); inside the function
keep calling stack_clear() as before, and update all callsites and references
(including any uses alongside clear_locals_and_stack()) to the new name to
maintain behavior; ensure public API/export names are adjusted and tests/uses
compile.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 97256480-8c7b-4237-bb71-6049292ef84a

📥 Commits

Reviewing files that changed from the base of the PR and between 5c29074 and 577f474.

📒 Files selected for processing (1)
  • crates/vm/src/frame.rs

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread crates/vm/src/frame.rs
Comment on lines +743 to 744
// Cell refs in fastlocals[nlocals..] are cleared by clear_locals_and_stack().
unsafe {

@coderabbitai coderabbitai Bot Mar 5, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# First, find the clear_stack_and_cells method definition and all callsites
rg -nP --type=rust -B2 -A8 'fn clear_stack_and_cells' crates/vm/src/frame.rs

Repository: RustPython/RustPython

Length of output: 607


🏁 Script executed:

#!/bin/bash
# Find all callsites of clear_stack_and_cells
rg -nP --type=rust '\bclear_stack_and_cells\s*\(' --max-count=50

Repository: RustPython/RustPython

Length of output: 279


🏁 Script executed:

#!/bin/bash
# Look at lines 743-744 and surrounding context to understand the comment
sed -n '735,755p' crates/vm/src/frame.rs | cat -n

Repository: RustPython/RustPython

Length of output: 1210


🏁 Script executed:

#!/bin/bash
# Check the callsite at crates/vm/src/builtins/frame.rs:702
sed -n '695,710p' crates/vm/src/builtins/frame.rs | cat -n

Repository: RustPython/RustPython

Length of output: 554


🏁 Script executed:

#!/bin/bash
# Also check context around line 752 in frame.rs for the other callsite
sed -n '748,760p' crates/vm/src/frame.rs | cat -n

Repository: RustPython/RustPython

Length of output: 704


Rename clear_stack_and_cells to clarify misleading semantics.

The method name and docstring claim it clears cell/free references, but the implementation only calls stack_clear(). The comment at line 743 explicitly states cells are cleared by clear_locals_and_stack() instead. Both callsites handle cells correctly (either cleared before the call or by the wrapper method), so no correctness issue exists, but renaming to clear_stack() would eliminate confusion about the method's actual responsibilities.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/vm/src/frame.rs` around lines 743 - 744, Rename the misleading method
clear_stack_and_cells() to clear_stack() and update its docstring to state it
only clears the value stack (delegating cell/free clearing to
clear_locals_and_stack()); inside the function keep calling stack_clear() as
before, and update all callsites and references (including any uses alongside
clear_locals_and_stack()) to the new name to maintain behavior; ensure public
API/export names are adjusted and tests/uses compile.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone youknowone mentioned this pull request Mar 5, 2026
Extract InterpreterFrame from Frame with Deref wrapper #7353
Merged
3 tasks done
@youknowone youknowone closed this in #7353 Mar 5, 2026
@youknowone
youknowone deleted the worktree-frame-datastack branch September 13, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@youknowone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.