about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2022-06-28 15:30:03 +0530
committerGitHub <noreply@github.com>2022-06-28 15:30:03 +0530
commit56b77869141efecc9daef02654bf0add552ad398 (patch)
tree6636a9b9a22532944788ea71485dea23fb00aa4e /compiler/rustc_codegen_llvm/src
parentec8477fea1989bb187ec026b2dad3e4b89d60e91 (diff)
parentc41630735c00187d54ae30ff0a7a98c1d689b831 (diff)
downloadrust-56b77869141efecc9daef02654bf0add552ad398.tar.gz
rust-56b77869141efecc9daef02654bf0add552ad398.zip
Rollup merge of #98384 - rdzhaafar:fix-macos-rss-reporting, r=davidtwco,michaelwoerister
Fix RSS reporting on macOS

> NOTE: This is a duplicate of #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);
```
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions