Skip to content

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Sep 27, 2025

Summary

This PR adds #[cold] attributes to error handling functions to improve performance by helping the compiler optimize for the common (non-error) path.

Changes

  • Added #[cold] attributes to error conversion functions in src/error.rs
  • Extracted error creation into separate cold functions in:
    • src/file_system.rs - UTF-8 validation error
    • src/specifier.rs - Empty specifier errors
    • src/windows/mod.rs - Unsupported path error

Benefits

The #[cold] attribute provides hints to the compiler that these functions are unlikely to be called, which enables:

  • Better code layout for CPU instruction cache efficiency
  • Reduced inline pressure in hot paths
  • Improved branch prediction
  • Overall better optimization of the happy path

Test Plan

  • All existing tests pass
  • cargo check passes
  • cargo clippy shows no warnings

🤖 Generated with Claude Code

Added #[cold] attributes to error handling functions and extracted error creation into separate cold functions. This optimization hint helps the compiler optimize for the common (non-error) path by:
- Reducing inline pressure in hot paths
- Improving branch prediction
- Better code layout for CPU instruction cache

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link

graphite-app bot commented Sep 27, 2025

How to use the Graphite Merge Queue

Add the label merge to this PR to add it to the merge queue.

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.

Copy link

codecov bot commented Sep 27, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.64%. Comparing base (bc9c219) to head (99889c0).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/file_system.rs 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #729      +/-   ##
==========================================
+ Coverage   94.63%   94.64%   +0.01%     
==========================================
  Files          15       15              
  Lines        2908     2914       +6     
==========================================
+ Hits         2752     2758       +6     
  Misses        156      156              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

codspeed-hq bot commented Sep 27, 2025

CodSpeed Performance Report

Merging #729 will not alter performance

Comparing perf-cold-error-paths (99889c0) with main (e2e2d65)1

Summary

✅ 7 untouched
⏩ 2 skipped2

Footnotes

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

  2. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Boshen Boshen merged commit cebe9fc into main Sep 27, 2025
15 checks passed
@Boshen Boshen deleted the perf-cold-error-paths branch September 27, 2025 14:17
This was referenced Sep 27, 2025
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