Skip to content

Commit

Permalink
(GH-2291) Enable bootsnap loadpath caching
Browse files Browse the repository at this point in the history
!feature

* **Enable bootsnap loadpath caching** ([#2291](#2291))

   Enable bootsnap loadpath caching
  • Loading branch information
jpogran committed Jan 19, 2021
1 parent e765bdd commit 87fa6ed
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions bolt.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Gem::Specification.new do |spec|

spec.add_dependency "addressable", '~> 2.5'
spec.add_dependency "aws-sdk-ec2", '~> 1'
spec.add_dependency "bootsnap", "~> 1.5"
spec.add_dependency "CFPropertyList", "~> 2.2"
spec.add_dependency "concurrent-ruby", "~> 1.0"
spec.add_dependency "ffi", "< 1.14.0"
Expand Down
14 changes: 14 additions & 0 deletions documentation/experimental_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,17 @@ To encrypt SSH connections using the unsupported algorithm
> option to shell out to SSH. See [the net-ssh
> README](https://github.com/net-ssh/net-ssh/#supported-algorithms) for a list of supported
> algorithms.
## Experimental Windows Performance Improvements

We are working to make executing Bolt on Windows much faster using several approaches. One of the ways is to use the `bootsnap` gem to cache the load paths to the gems Bolt uses.

To enable this performance improvement set the BOLT_BOOTSNAP environment variable to true before executing any commands.

```
PS C:\Users\Administrator> $env:BOLT_BOOTSNAP = 'true'
PS C:\Users\Administrator> bolt command run 'echo hello' -t localhost
```
This can be added to your PowerShell profile while evaluating until this experimental feature is folded into the product.

> Note that the first run of Bolt after enabling caching will take much longer than a normal run. All subsequent runs after will perform faster.
15 changes: 15 additions & 0 deletions exe/bolt
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

bootsnap_enabled = ENV['BOLT_BOOTSNAP'] || false
if bootsnap_enabled
require 'bootsnap'
cache = File.join(ENV['USERPROFILE'], '.puppetlabs', 'etc', 'bolt')
Bootsnap.setup(
cache_dir: cache, # Path to your cache
development_mode: false, # Current working environment, e.g. RACK_ENV, RAILS_ENV, etc
load_path_cache: true, # Optimize the LOAD_PATH with a cache
autoload_paths_cache: false, # Optimize ActiveSupport autoloads with cache
disable_trace: false, # Set `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
compile_cache_iseq: true, # Compile Ruby code into ISeq cache, breaks coverage reporting.
compile_cache_yaml: true # Compile YAML into a cache
)
end

require 'bolt'
require 'bolt/cli'

Expand Down

0 comments on commit 87fa6ed

Please sign in to comment.