Skip to content

perf: optimize filterable op mechanism for no-filter case#839

Merged
reubeno merged 2 commits intofilterfrom
copilot/sub-pr-838
Dec 10, 2025
Merged

perf: optimize filterable op mechanism for no-filter case#839
reubeno merged 2 commits intofilterfrom
copilot/sub-pr-838

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 10, 2025

The filterable op mechanism introduced measurable overhead even when no filters are installed, as shown by benchmark regressions.

Changes

brush-core/src/filter.rs:

  • Added #[inline] to do_with_filter to enable call-site inlining
  • Extracted filter execution to do_with_filter_slow marked #[cold]

Impact

For the no-filter case (the common path):

  • #[inline] allows the compiler to optimize away the None check
  • #[cold] on the slow path improves branch prediction

The clone of Option<Arc<Mutex<F>>> at call sites remains necessary due to borrow checker constraints (closures need owned values), but it's cheap (atomic increment).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Dec 10, 2025
- Add #[inline] to do_with_filter to enable better optimization
- Split slow path into separate #[cold] function to optimize branch prediction
- The common case (no filter) now has minimal overhead with better inlining

Co-authored-by: reubeno <10508433+reubeno@users.noreply.github.com>
Copilot AI changed the title [WIP] Analyze and propose changes to reduce no-op overhead perf: optimize filterable op mechanism for no-filter case Dec 10, 2025
Copilot AI requested a review from reubeno December 10, 2025 02:52
@reubeno reubeno marked this pull request as ready for review December 10, 2025 03:05
@reubeno reubeno merged commit 5f8640e into filter Dec 10, 2025
33 of 56 checks passed
@reubeno reubeno deleted the copilot/sub-pr-838 branch December 10, 2025 03:17
reubeno pushed a commit that referenced this pull request Dec 14, 2025
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
reubeno pushed a commit that referenced this pull request Dec 15, 2025
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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.

2 participants