Skip to content
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

Add a mode to run a ruby process directly #38

Open
javierhonduco opened this issue Sep 25, 2022 · 0 comments
Open

Add a mode to run a ruby process directly #38

javierhonduco opened this issue Sep 25, 2022 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@javierhonduco
Copy link
Owner

Summary

This is a feature that several people have brought up. The idea would be to spawn a Ruby process directly and start profiling it. So instead of having to do this

# in one terminal or in the background
$ bundler run my_ruby_app
$ rbperf record --pid `pidof my_ruby_app` cpu

We could do

$ rbperf record --exec 'bundler run my_ruby_app' cpu

Possible implementation

This feature needs to control the execution of another process so the ptrace(2) system call is a good fit.

Something that this implementation might have to handle is the race condition between the moment when the process is executed and when all the libraries have been mapped in memory as there's a window when libruby, in the case of dynamically compiled CRuby, might not be mapped into memory yet, and we would have to fail to find the global data that rbperf needs to read

rbperf/src/process.rs

Lines 73 to 76 in 48ce25b

let ruby_version = ruby_version(&bin_path).unwrap();
debug!("Binary {:?}", bin_path);
let symbol = ruby_current_vm_address(&bin_path, &ruby_version)?;

@javierhonduco javierhonduco added help wanted Extra attention is needed good first issue Good for newcomers labels Sep 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant