⚡ Bolt: Avoid eager clone of entire Surface struct in WorkspaceModel - #391
⚡ Bolt: Avoid eager clone of entire Surface struct in WorkspaceModel#391Lucenx9 wants to merge 1 commit into
Conversation
Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR updates ChangesSurface lookup optimization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4efd1cf9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,4 @@ | |||
|
|
|||
| ## 2024-05-18 - Avoid Cloning Large Structs From The Model | |||
There was a problem hiding this comment.
Remove the one-off .jules directory
This file introduces .jules/ as a new top-level bucket solely for a tool-specific optimization note, rather than a durable repository content category or documentation colocated with the owning crate. Remove this artifact, or move genuinely durable guidance under the existing docs/ or crate structure, to keep the repository shape predictable.
AGENTS.md reference: AGENTS.md:L131-L131
Useful? React with 👍 / 👎.
💡 What: Refactored
WorkspaceModelmethods (split_with,add_tab,prepare_root_surface_replacement,close_surface_with_replacement) to avoid eagerly cloning the entireSurfacestruct at the start of the function. Instead, the struct is borrowed, and only the required scalar fields (likeworkspace_idandcwd) are cloned before performing validation checks.🎯 Why: The
Surfacestruct is large because it contains apersisted_scrollbackbuffer (Option<String>) that can be up to 64KB. Callingclone()on it just to retrieve the workspace ID for a fast pre-validation check forces an unnecessary and expensive heap allocation. Early returns from these checks would still incur this cost.📊 Impact: Reduces heap allocations and completely eliminates copying up to 64KB of buffer data on validation paths when closing or creating surfaces.
🔬 Measurement: Profile the allocations with memory analyzers during repeated split/close operations in workspaces heavily populated with large scrollback buffers.
PR created automatically by Jules for task 18319778361575855755 started by @Lucenx9
Summary
WorkspaceModelsurface handling to borrowSurfacevalues.workspace_idandcwd.persisted_scrollbackbuffer copies.Impact