这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Nov 2, 2025

Summary

Refactors read_to_string_bypass_system_cache to use cfg_if for cleaner platform-specific code and replaces unsafe libc::posix_fadvise with safe rustix::fs::fadvise on Linux.

Changes

  • Code structure: Refactored to use cfg_if! macro for platform-specific implementations
  • Linux: Replaced unsafe { libc::posix_fadvise(...) } with rustix::fs::fadvise(...)
  • macOS: Unchanged (still uses F_NOCACHE)
  • Other platforms: Unchanged (falls back to read_to_string)

Benefits

  • Safer: Eliminates unsafe block for posix_fadvise on Linux
  • Cleaner: Consistent use of cfg_if! across file_system.rs
  • Same performance: rustix::fs::fadvise is a safe wrapper around posix_fadvise
  • Better structure: Matches the pattern used in metadata functions

Testing

  • All existing tests pass
  • Clippy checks pass
  • Code formatted

@graphite-app
Copy link

graphite-app bot commented Nov 2, 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.

@Boshen Boshen force-pushed the refactor/bypass-cache-cfg-if branch from 5a450a1 to 8690ebe Compare November 2, 2025 07:06
@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.63%. Comparing base (1380ac2) to head (1361c90).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #802   +/-   ##
=======================================
  Coverage   93.63%   93.63%           
=======================================
  Files          17       17           
  Lines        3095     3095           
=======================================
  Hits         2898     2898           
  Misses        197      197           

☔ 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Nov 2, 2025

CodSpeed Performance Report

Merging #802 will not alter performance

Comparing refactor/bypass-cache-cfg-if (1361c90) with main (1380ac2)1

Summary

✅ 10 untouched
⏩ 5 skipped2

Footnotes

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

  2. 5 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 marked this pull request as ready for review November 2, 2025 12:16
@Boshen Boshen added the merge label Nov 2, 2025
Copy link
Member Author

Boshen commented Nov 2, 2025

Merge activity

…#802)

## Summary

Refactors `read_to_string_bypass_system_cache` to use `cfg_if` for cleaner platform-specific code and replaces unsafe `libc::posix_fadvise` with safe `rustix::fs::fadvise` on Linux.

## Changes

- **Code structure**: Refactored to use `cfg_if!` macro for platform-specific implementations
- **Linux**: Replaced `unsafe { libc::posix_fadvise(...) }` with `rustix::fs::fadvise(...)`
- **macOS**: Unchanged (still uses `F_NOCACHE`)
- **Other platforms**: Unchanged (falls back to `read_to_string`)

## Benefits

- **Safer**: Eliminates unsafe block for `posix_fadvise` on Linux
- **Cleaner**: Consistent use of `cfg_if!` across `file_system.rs`
- **Same performance**: `rustix::fs::fadvise` is a safe wrapper around `posix_fadvise`
- **Better structure**: Matches the pattern used in `metadata` functions

## Testing

- All existing tests pass
- Clippy checks pass
- Code formatted
@graphite-app graphite-app bot force-pushed the refactor/bypass-cache-cfg-if branch from 1207281 to 1361c90 Compare November 2, 2025 12:17
@graphite-app graphite-app bot merged commit 1361c90 into main Nov 2, 2025
18 checks passed
@graphite-app graphite-app bot deleted the refactor/bypass-cache-cfg-if branch November 2, 2025 12:21
@Boshen Boshen mentioned this pull request Nov 2, 2025
@graphite-app graphite-app bot removed the merge label Nov 2, 2025
@Boshen Boshen mentioned this pull request Nov 5, 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.

2 participants