Skip to content

⚡ Bolt: [performance improvement] - #398

Open
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-opt-push-tab-clone-5526539822405237728
Open

⚡ Bolt: [performance improvement]#398
Lucenx9 wants to merge 1 commit into
mainfrom
bolt-opt-push-tab-clone-5526539822405237728

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

💡 What: Changed push_tab_to_leaf to accept &SurfaceId instead of an owned SurfaceId.
🎯 Why: The previous implementation eagerly cloned new_tab_id inside .any() at each split node level during pane tree traversal, causing redundant heap allocations.
📊 Impact: Eliminates O(N) redundant String allocations (where N is the depth of the split tree) when pushing new tabs to a leaf pane.
🔬 Measurement: Profiling allocation calls during heavy pane splitting/tab creation will show reduced String::clone invocations.


PR created automatically by Jules for task 5526539822405237728 started by @Lucenx9

Summary

  • push_tab_to_leaf now borrows SurfaceId during pane-tree traversal.
  • The code clones SurfaceId only when inserting it into a leaf.
  • This removes redundant String allocations during tab creation and pane splitting.
  • User-visible behavior is unchanged.

Impact

  • GTK/VTE: No impact.
  • Socket/core Rust: Core Rust allocation behavior improves. No public API changes.
  • Tests: No test changes reported.
  • Security and privacy: No impact.

💡 What: Changed `push_tab_to_leaf` to accept `&SurfaceId` instead of an owned `SurfaceId`.
🎯 Why: The previous implementation eagerly cloned `new_tab_id` inside `.any()` at each split node level during pane tree traversal, causing redundant heap allocations.
📊 Impact: Eliminates O(N) redundant `String` allocations (where N is the depth of the split tree) when pushing new tabs to a leaf pane.
🔬 Measurement: Profiling allocation calls during heavy pane splitting/tab creation will show reduced `String::clone` invocations.

Co-authored-by: Lucenx9 <185146821+Lucenx9@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1b6b1eac-3a94-40cf-9b56-816a4c34efd6

📥 Commits

Reviewing files that changed from the base of the PR and between 7b0afc0 and b277d85.

📒 Files selected for processing (3)
  • .jules/bolt.md
  • crates/forktty-core/src/model.rs
  • crates/forktty-core/src/model/pane_tree.rs

📝 Walkthrough

Walkthrough

The tab insertion path now borrows SurfaceId during pane-tree traversal and clones it only when inserting the tab. A Rust guideline records this deferred-cloning pattern.

Changes

Tab ID allocation

Layer / File(s) Summary
Borrow SurfaceId during tab insertion
crates/forktty-core/src/model.rs, crates/forktty-core/src/model/pane_tree.rs, .jules/bolt.md
add_tab and recursive push_tab_to_leaf calls pass SurfaceId by reference. push_tab_to_leaf clones the ID only when inserting it into a leaf. The guideline documents this pattern.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: rust

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title identifies a performance improvement, which matches the changes, but it does not describe the affected Rust pane-tree area.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Privacy Boundary ✅ Passed The patch only changes Rust ownership in local pane-tree tab insertion and adds a performance guideline; it adds no telemetry, network calls, or output persistence.
Terminal Command Safety ✅ Passed HEAD changes only pane-tree tab insertion and a performance note; no PTY, socket, worktree, shell, packaging, or notification command execution changes are present.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-opt-push-tab-clone-5526539822405237728

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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b277d8540c

ℹ️ 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".

Comment thread .jules/bolt.md
Comment on lines +1 to +3
## 2024-05-24 - [Avoid eager allocations in tree traversal callbacks]
**Learning:** In Rust, avoid calling `.clone()` on values like `String` inside iterator closures such as `.any()` during tree traversals. This causes eager, redundant allocations when deferring the `clone()` inside the callback match point saves unnecessary heap allocations.
**Action:** Pass references down the call stack for search predicates, and only invoke `.clone()` once the insertion or match point is definitively reached.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the tool-specific top-level learning directory

This commit creates a new .jules/ root bucket solely for a generic automation-tool learning note; it is not used by ForkTTY's product, build, or contributor documentation. The repository requires new top-level directories to represent durable categories of repository content, so omit this artifact or move genuinely project-specific guidance into an existing documentation location.

AGENTS.md reference: AGENTS.md:L131-L131

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant