-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix memory profiling on macOS #98164
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
the
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
label
Jun 16, 2022
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @michaelwoerister (or someone else) soon. Please see the contribution instructions for more information. |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Jun 16, 2022
This commit adds a new unstable attribute, `#[doc(tuple_varadic)]`, that shows a 1-tuple as `(T, ...)` instead of just `(T,)`, and links to a section in the tuple primitive docs that talks about these.
Before: impl<T, U> UnwindSafe for (T, ...) where T: UnwindSafe, U: UnwindSafe, After: impl<T> UnwindSafe for (T, ...) where T: UnwindSafe,
Co-authored-by: Jacob Hoffman-Andrews <[email protected]>
Co-authored-by: Jacob Hoffman-Andrews <[email protected]>
Co-authored-by: Jacob Hoffman-Andrews <[email protected]>
Just found out that |
Closing this PR, because I messed up git workflow |
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Jun 28, 2022
…r=davidtwco,michaelwoerister Fix RSS reporting on macOS > NOTE: This is a duplicate of rust-lang#98164, which I closed because I borked my rustc fork Currently, `rustc_data_structures::profiling::get_resident_set_size()` always returns `None` on macOS. This is because macOS does not implement procfs used in the unix version of the function: ```rust ... else if #[cfg(unix)] { pub fn get_resident_set_size() -> Option<usize> { let field = 1; let contents = fs::read("/proc/self/statm").ok()?; let contents = String::from_utf8(contents).ok()?; let s = contents.split_whitespace().nth(field)?; let npages = s.parse::<usize>().ok()?; Some(npages * 4096) } ... ``` The proposed solution uses libproc, and more specifically `proc_pidinfo`, which has been available on macOS since 10.5 if the function signature inside libproc.h is to be believed: ```c int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); ```
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Jun 28, 2022
…r=davidtwco,michaelwoerister Fix RSS reporting on macOS > NOTE: This is a duplicate of rust-lang#98164, which I closed because I borked my rustc fork Currently, `rustc_data_structures::profiling::get_resident_set_size()` always returns `None` on macOS. This is because macOS does not implement procfs used in the unix version of the function: ```rust ... else if #[cfg(unix)] { pub fn get_resident_set_size() -> Option<usize> { let field = 1; let contents = fs::read("/proc/self/statm").ok()?; let contents = String::from_utf8(contents).ok()?; let s = contents.split_whitespace().nth(field)?; let npages = s.parse::<usize>().ok()?; Some(npages * 4096) } ... ``` The proposed solution uses libproc, and more specifically `proc_pidinfo`, which has been available on macOS since 10.5 if the function signature inside libproc.h is to be believed: ```c int proc_pidinfo(int pid, int flavor, uint64_t arg, void *buffer, int buffersize) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_2_0); ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently,
rustc_data_structures::profiling::get_resident_set_size()
always returnsNone
on macOS.This proposed solution uses proc_pidinfo(...) from libproc. This function is available on any mac since 10.5
if the function signature in
libproc.h
is to be believed:P.S: This is my first pull request to the Rust project. I'm open to criticism in case I messed something up.