-
-
Notifications
You must be signed in to change notification settings - Fork 34
refactor: use cfg_if and rustix in read_to_string_bypass_system_cache #802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
How to use the Graphite Merge QueueAdd 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. |
5a450a1 to
8690ebe
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
CodSpeed Performance ReportMerging #802 will not alter performanceComparing Summary
Footnotes
|
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
1207281 to
1361c90
Compare
Summary
Refactors
read_to_string_bypass_system_cacheto usecfg_iffor cleaner platform-specific code and replaces unsafelibc::posix_fadvisewith saferustix::fs::fadviseon Linux.Changes
cfg_if!macro for platform-specific implementationsunsafe { libc::posix_fadvise(...) }withrustix::fs::fadvise(...)F_NOCACHE)read_to_string)Benefits
posix_fadviseon Linuxcfg_if!acrossfile_system.rsrustix::fs::fadviseis a safe wrapper aroundposix_fadvisemetadatafunctionsTesting