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 optional ruby-profiling with --profile-ruby #4034

Merged
merged 4 commits into from
Oct 13, 2015

Conversation

lamont-granquist
Copy link
Contributor

dumps a large call graph into /var/chef/cache/graph_profile.out

dumps a large call graph into /var/chef/cache/graph_profile.out
@lamont-granquist
Copy link
Contributor Author

I've been using this a lot lately. Seems it would be good to get it into PR shape and let other people play with it.

@chef/client-core review?

@@ -53,6 +53,11 @@
require 'chef/mixin/deprecation'
require 'ohai'
require 'rbconfig'
begin
require 'ruby-prof'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not do this in start_profiling or profiling_prereqs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 of one, half dozen of the other? I certainly can...

@coderanger
Copy link
Contributor

I feel like maybe this shouldn't show in the --help output as it is likely to be a red herring for users that want to profile their recipe code? Or at least if we want this to be a part of user workflows, we would need some tools to make it easier to filter user code vs. core code, etc.

@jaym
Copy link
Contributor

jaym commented Oct 6, 2015

👍 huge fan

@ranjib
Copy link
Contributor

ranjib commented Oct 6, 2015

agree with @coderanger , given chef-client does not have dependency on ruby-prof, it feels strange to expose this as CLI flag. a config option should be good enough
👍

@jaym
Copy link
Contributor

jaym commented Oct 6, 2015

Are there any downsides to making it a dependency? I've had to walk people through profiling chef runs and having this just work would be awesome. I agree that it's not the most perfect feature, but it's still very useful.

@coderanger
Copy link
Contributor

@jaym I would say it would fall under the kind of thing to include with the omnibus packages but not actually be a dependency (for those of us left that still install via gems).

@lamont-granquist
Copy link
Contributor Author

Its a dev dependency for that reason. 'gem install chef' won't pull it in, but 'bundle install' (not --without development) will, so it'll get shipped in omnibus.

And whats the API to hide it from --help?

@danielsdeleo
Copy link
Contributor

There isn't a way to hide things from help in mixlib-cli (or else we would have done this with some other flags we added just for tests). I suppose you could detect whether the gem is available at file load time and then surround the option call with an if statement. Otherwise you could add more explanatory text to the description.

@lamont-granquist
Copy link
Contributor Author

If I omit the description it still shows up in --help. I really want it a CLI option because temporarily adding it to /etc/chef/client.rb is fussy, particularly if you have chef managing client.rb and have to edit it on every run. I avoided adding it as a config option, since I don't think people will want to have this option running on every run, particularly since the outfile gets truncated and its not a log (and that seems like a good way to DoS your disk space if we made it a log since the call graph is huge).

@lamont-granquist
Copy link
Contributor Author

yeah, i could if defined? it, but if the gem is shipped with the omnibus packages, then it'll load for nearly everyone anyway, which defeats the purpose...

@danielsdeleo
Copy link
Contributor

I guess it depends on the purpose. If we just don't want to make a hard dep on the profiler gem, that'd be fine, if we want only expose this to users who know it's there, then it wouldn't help.

@thommay
Copy link
Contributor

thommay commented Oct 6, 2015

I definitely agree this makes much more sense as a CLI flag than a config option. If you make with some typey-typey to make it really obvious what this does in the description I think we're good.

@danielsdeleo
Copy link
Contributor

I'm in agreement with @thommay's suggestion.

@coderanger
Copy link
Contributor

Yeah, not worth a ton of work to add hidden CLI args, but something to warn off peoples would be nice. Also would be good to move the require I think so it doesn't add to the load time for the 99% of users that don't need it (but will have the gem thanks to omnibus et al). That's a minor issue though, a few more requires aren't going to be super noticeable.

@lamont-granquist
Copy link
Contributor Author

Made the description substantially more scary.

I'll move the load in a sec, lazying the load time does marginally win in my mind over grouping the requires together.

@coderanger
Copy link
Contributor

👍

require 'ruby-prof'
rescue LoadError
raise "You must have the ruby-prof gem installed in order to use --profile-ruby"
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a truly trivial nitpick, the begin is redundant here no?

@thommay
Copy link
Contributor

thommay commented Oct 7, 2015

I'm 👍 regardless of my comment

@@ -52,6 +52,12 @@ class Chef::Application::Solo < Chef::Application
:boolean => true,
:default => false

option :profile_ruby,
:long => "--[no-]profile-ruby",
:description => "Output ruby execution profile graph",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to copy the scary here, too?

@danielsdeleo
Copy link
Contributor

Probably want to update the description for the CLI option for solo and apply also. 👍 aside from that.

lamont-granquist added a commit that referenced this pull request Oct 13, 2015
add optional ruby-profiling with --profile-ruby
@lamont-granquist lamont-granquist merged commit 92ba97d into master Oct 13, 2015
@lamont-granquist lamont-granquist deleted the lcg/ruby-profiling branch October 13, 2015 19:11
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants