Why is knife --help so slow?


#1

Hey all,

I have a bash_completion script that calls “knife --help” to get a list of
suggestions. The script works great, but each call costs about 2 seconds
due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting help
info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


#2

It has to process every gem on the system looking for knife plugins. If you strace it, you’ll see a crazy number of stats and similar calls.

–Noah

On Oct 9, 2013, at 1:53 PM, DV vindimy@gmail.com wrote:

Hey all,

I have a bash_completion script that calls “knife --help” to get a list of suggestions. The script works great, but each call costs about 2 seconds due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting help info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


#3

I recently ran into this problem myself. The way I got around it was
upgrading to ruby 2.0.0 via rvm and created a gem set specifically to
chef/knife stuff. It worked great for me, maybe give that a shot?

Best Regards,
JJ Asghar
e: jj.asghar@peopleadmin.com | c: 512.619.0722 | o: 512.977.5876

On 10/9/13 3:55 PM, “Noah Kantrowitz” noah@coderanger.net wrote:

It has to process every gem on the system looking for knife plugins. If
you strace it, you’ll see a crazy number of stats and similar calls.

–Noah

On Oct 9, 2013, at 1:53 PM, DV vindimy@gmail.com wrote:

Hey all,

I have a bash_completion script that calls “knife --help” to get a list
of suggestions. The script works great, but each call costs about 2
seconds due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting
help info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


#4

Thanks guys, I’ll give gemset a try.

On Wed, Oct 9, 2013 at 2:00 PM, JJ Asghar jj.asghar@peopleadmin.com wrote:

I recently ran into this problem myself. The way I got around it was
upgrading to ruby 2.0.0 via rvm and created a gem set specifically to
chef/knife stuff. It worked great for me, maybe give that a shot?

Best Regards,
JJ Asghar
e: jj.asghar@peopleadmin.com | c: 512.619.0722 | o: 512.977.5876

On 10/9/13 3:55 PM, “Noah Kantrowitz” noah@coderanger.net wrote:

It has to process every gem on the system looking for knife plugins. If
you strace it, you’ll see a crazy number of stats and similar calls.

–Noah

On Oct 9, 2013, at 1:53 PM, DV vindimy@gmail.com wrote:

Hey all,

I have a bash_completion script that calls “knife --help” to get a list
of suggestions. The script works great, but each call costs about 2
seconds due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting
help info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#5

Or use bundler (Gemfile + ‘bundle exec knife help’) if you have a plain
ruby install and not rvm
On Oct 10, 2013 6:39 AM, “DV” vindimy@gmail.com wrote:

Thanks guys, I’ll give gemset a try.

On Wed, Oct 9, 2013 at 2:00 PM, JJ Asghar jj.asghar@peopleadmin.comwrote:

I recently ran into this problem myself. The way I got around it was
upgrading to ruby 2.0.0 via rvm and created a gem set specifically to
chef/knife stuff. It worked great for me, maybe give that a shot?

Best Regards,
JJ Asghar
e: jj.asghar@peopleadmin.com | c: 512.619.0722 | o: 512.977.5876

On 10/9/13 3:55 PM, “Noah Kantrowitz” noah@coderanger.net wrote:

It has to process every gem on the system looking for knife plugins. If
you strace it, you’ll see a crazy number of stats and similar calls.

–Noah

On Oct 9, 2013, at 1:53 PM, DV vindimy@gmail.com wrote:

Hey all,

I have a bash_completion script that calls “knife --help” to get a list
of suggestions. The script works great, but each call costs about 2
seconds due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting
help info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


Best regards, Dmitriy V.


#6

Honestly gemset didn’t reduce the “knife --help” time by much - maybe 20%
at best. I’ll try bundler.

On Thu, Oct 10, 2013 at 10:06 AM, Torben Knerr ukio@gmx.de wrote:

Or use bundler (Gemfile + ‘bundle exec knife help’) if you have a plain
ruby install and not rvm
On Oct 10, 2013 6:39 AM, “DV” vindimy@gmail.com wrote:

Thanks guys, I’ll give gemset a try.

On Wed, Oct 9, 2013 at 2:00 PM, JJ Asghar jj.asghar@peopleadmin.comwrote:

I recently ran into this problem myself. The way I got around it was
upgrading to ruby 2.0.0 via rvm and created a gem set specifically to
chef/knife stuff. It worked great for me, maybe give that a shot?

Best Regards,
JJ Asghar
e: jj.asghar@peopleadmin.com | c: 512.619.0722 | o: 512.977.5876

On 10/9/13 3:55 PM, “Noah Kantrowitz” noah@coderanger.net wrote:

It has to process every gem on the system looking for knife plugins. If
you strace it, you’ll see a crazy number of stats and similar calls.

–Noah

On Oct 9, 2013, at 1:53 PM, DV vindimy@gmail.com wrote:

Hey all,

I have a bash_completion script that calls “knife --help” to get a
list

of suggestions. The script works great, but each call costs about 2
seconds due to “knife --help” taking this long.

Any ideas why it’s so slow? It isn’t doing anything, just outputting
help info. Should take under a millisecond, right?

$ time knife node --help >/dev/null 2>&1

real 0m0.878s
user 0m0.776s
sys 0m0.100s


Best regards, Dmitriy V.


Best regards, Dmitriy V.


Best regards, Dmitriy V.