[BOLT-1119] Improve Bolt startup time on Windows for bolt --help Created: 2019/02/08  Updated: 2019/03/26  Resolved: 2019/03/20

Status: Resolved
Project: Puppet Task Runner
Component/s: None
Affects Version/s: None
Fix Version/s: BOLT 1.15.0

Type: Task Priority: Normal
Reporter: Yasmin Rajabi Assignee: Cas Donoghue
Resolution: Fixed Votes: 0
Labels: docs_reviewed, windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
blocks BOLT-1186 Improve Bolt startup time on Windows ... Resolved
relates to BOLT-1208 SPIKE - Determine next area for Windo... Closed
Team: Bolt
Sprint: Bolt Kanban
Release Notes: Enhancement
Release Notes Summary: Improvements to bolt startup time on windows OS.
QA Risk Assessment: Needs Assessment

Comment by Ethan Brown [ 2019/03/12 ]

Using a Windows 10 local VM with Ruby 2.5 and running Ruby / Bolt from source (with bundler) inside the ruby-prof profiler has generated some useful information.  A typical bundle exec bolt --help on a clean system takes about 4.5 seconds. By comparison, simply loading irb takes under a second.


There are two areas to further explore:


  • About 85% of the time is spent in Rubys Kernel.require. While it's unlikely that performance of that core Ruby call can be improved, we may be able to make some optimizations around when code is loaded. In areas where code can be lazy loaded, it may be advantageous to do so, since expectations are that a typical --help should respond immediately. Next step is to add something like https://github.com/ruby-prof/ruby-prof/issues/159 to introduce more diagnostic information / analyze further. It's not yet determined if the majority of this time is loading PAL (Puppet As Library) - which it very well may be.
  • 15% of the time is spent in a gem scan performed by the LittlePlugger gem - specifically in this line - https://github.com/TwP/little-plugger/blob/master/lib/little-plugger.rb#L191 (It's possible that loggers plugin system may be disabled to avoid running this code path). Note that both Bolt and the winrm gem rely on this library.


A couple of additional notes:


  • Focus thus far has been on the most simple of cases - improving the experience around loading Bolt help. Additional work is still TBD for loading actual module / plan code and metadata, running tasks, etc.
  • At least in this test environment, installing more gem code to the Ruby module path appears to degrade performance. Run times of 4.5 seconds lengthen to 5+ seconds. Other local changes have caused runs to degrade to 12+ seconds (still investigating if this is an anomaly or reproducible)
Comment by Melissa Amos [ 2019/03/20 ]

To clarify, this improves startup time for Bolt help, specifically, correct? (The release notes summary just says improve Bolt startup time).

Is there anything more to be said here, user-facing? Even estimated improvement in seconds would give me some content for the actual body of the release note.

Comment by Cas Donoghue [ 2019/03/20 ]

I would imagine it helps for bolt --version or just running bolt (which is the same as bolt --help. I view this work as kind of a pre-cursor to BOLT-1186. I think that it is important to call out in the release note because it changes the way gems are loaded and can therefor possibly have unforeseen consequences, but as a first step there is not a really catchy headline for the release note.
Also now that I think about it the load time would theoretically be improved for all OS, not just windows. So maybe just

Improve bolt load time (1.15.0)
Bolt startup time has been made more efficient.

Comment by Ethan Brown [ 2019/03/22 ]

My tests have been confined to a single host / scenario, so I'm not entirely comfortable with advertising "% faster" or absolute times improvements like "3 seconds faster" as that can be wildly variable based on machine.

The focus of this work has been primarily on improving the path to something like bolt --help for now, but will expand out to encompass other common operations in later tickets / efforts. So for now, it's been about not loading code that we'll never need OR lazy-loading code when we need it (which will make small improvements across all operating systems - regardless of whether or not we're just asking for bolt --help or doing real work).

That's a long winded way of saying that what you have in the docs is entirely sufficient.

Generated at Fri Oct 18 01:19:40 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.