Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Aug 27, 2025

Follow-on after #12724. Small perf optimization.

Cell is cheaper than RefCell, because it doesn't do runtime aliasing checks. It's preferable when the contained type is small and Copy, as is the case here (usize).

@github-actions github-actions bot added A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance labels Aug 27, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@overlookmotel overlookmotel marked this pull request as ready for review August 27, 2025 15:18
Copilot AI review requested due to automatic review settings August 27, 2025 15:18
@overlookmotel overlookmotel requested a review from camc314 as a code owner August 27, 2025 15:18
@overlookmotel overlookmotel requested a review from Sysix August 27, 2025 15:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes the linter's ContextHost struct by replacing RefCell<usize> with Cell<usize> for the current_sub_host_index field. This is a performance optimization that leverages Cell's lower overhead compared to RefCell when dealing with small Copy types.

  • Replace RefCell<usize> with Cell<usize> for current_sub_host_index
  • Update all usage patterns to use Cell's get() and set() methods instead of borrow() and borrow_mut()
  • Refactor the next_sub_host method to use bounds checking instead of relying on Option::is_some()

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 27, 2025

CodSpeed Instrumentation Performance Report

Merging #13330 will not alter performance

Comparing 08-27-perf_linter_use_cell_instead_of_refcell_ (827fe1c) with main (9c9f80d)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (827fe1c) during the generation of this report, so 9c9f80d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Aug 27, 2025
Copy link
Member Author

overlookmotel commented Aug 27, 2025

Merge activity

Follow-on after #12724. Small perf optimization.

`Cell` is cheaper than `RefCell`, because it doesn't do runtime aliasing checks. It's preferable when the contained type is small and `Copy`, as is the case here (`usize`).
@graphite-app graphite-app bot force-pushed the 08-27-perf_linter_use_cell_instead_of_refcell_ branch from 56adaaf to 827fe1c Compare August 27, 2025 15:23
@graphite-app graphite-app bot merged commit 827fe1c into main Aug 27, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-27-perf_linter_use_cell_instead_of_refcell_ branch August 27, 2025 15:27
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants