Module: Homebrew::Bootsnap Private
- Defined in:
- startup/bootsnap.rb,
startup/bootsnap.rbi
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
- .key ⇒ String private
- .load!(compile_cache: true) ⇒ void private
-
.prewarm! ⇒ Object
private
Compile caches for the load graphs of common commands in a detached background process, so the next
brewcommand doesn't pay the cost of compiling caches for Ruby files changed by e.g. - .reset! ⇒ void private
Class Method Details
.key ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'startup/bootsnap.rb', line 6 def self.key @key ||= begin require "digest/sha2" checksum = Digest::SHA256.new checksum << RUBY_VERSION checksum << RUBY_PLATFORM checksum << Dir.children(File.join(Gem.paths.path, "gems")).join(",") checksum.hexdigest end end |
.load!(compile_cache: true) ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'startup/bootsnap.rb', line 40 def self.load!(compile_cache: true) return unless enabled? begin require ENV.fetch("HOMEBREW_BOOTSNAP_GEM_PATH") rescue LoadError return end ::Bootsnap.setup( cache_dir:, ignore_directories:, # In development environments the bootsnap compilation cache is # generated on the fly when source files are loaded. # https://github.com/Shopify/bootsnap?tab=readme-ov-file#precompilation development_mode: true, load_path_cache: true, # Ruby refuses InstructionSequence#to_binary while Coverage is active. compile_cache_iseq: compile_cache && ENV["HOMEBREW_TESTS_COVERAGE"].nil?, compile_cache_yaml: compile_cache, ) end |
.prewarm! ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Compile caches for the load graphs of common commands in a detached
background process, so the next brew command doesn't pay the cost of
compiling caches for Ruby files changed by e.g. brew update.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'startup/bootsnap.rb', line 76 def self.prewarm! return unless enabled? return if ENV["HOMEBREW_TESTS"] pid = Process.spawn( *HOMEBREW_RUBY_EXEC_ARGS, "-I", $LOAD_PATH.join(File::PATH_SEPARATOR), "-rglobal", "-rcmd/install", "-rcmd/fetch", "-rcmd/upgrade", "-e", "", in: File::NULL, out: File::NULL, err: File::NULL, pgroup: true ) Process.detach(pid) rescue SystemCallError nil end |
.reset! ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
63 64 65 66 67 68 69 70 71 |
# File 'startup/bootsnap.rb', line 63 def self.reset! return unless enabled? ::Bootsnap.unload_cache! @key = nil # The compile cache doesn't get unloaded so we don't need to load it again! load!(compile_cache: false) end |