Refactor file collection logic to exclude lib/ directory#21639
Refactor file collection logic to exclude lib/ directory#21639dwelch-r7 wants to merge 1 commit into
Conversation
|
Are we sure we want this change? 👀 If a mixin change in |
Yep, that is true but a vast majority of the time it doesn't affect the metadata so almost everytime I boot up framework the cache needs to rebuild even though the metadata is the same |
|
I have another PR here #21645 which we can land along with this one or instead of if we don't want to skip lib files but I think at least one of these should land if not both |
Description
Remove
lib/from the boot-time checksum validation scope inMsf::Modules::Metadata::Store.collect_files_to_check.The checksum validation determines whether module files have changed since the metadata cache was last built. When files have changed, it forces immediate (non-deferred) module loading. Previously, this included all files under
lib/(~3000+ files), meaning any library change would invalidate the module metadata cache and trigger a full module reload — even though library changes don't affect the cached metadata (module name, author, platform, references, etc.).This reduces the number of files checksummed on every boot from ~7000+ to ~4000 (modules only), and eliminates false cache invalidations caused by unrelated library edits during development.
Related Issue:
Breaking Changes
If a mixin change in
lib/alters module metadata (e.g., changes default targets or platform support), the metadata cache will not automatically invalidate. Users can runreload_allto force a rebuild.Verification Steps
msfconsolenormally, confirm it boots without errorlib/(e.g.,touch lib/msf/core/exploit.rb), restartmsfconsole— it should still boot with deferred module loads (fast path) since lib changes no longer invalidate the checksummodules/(e.g.,touch modules/exploits/multi/handler.rb), restartmsfconsole— it should detect the change and force immediate module loadingbundle exec rspec spec/lib/msf/core/modules/metadata/store_spec.rb— all 5 examples passTest Evidence
Before
hyperfine --warmup 3 "bundle exec ruby ./msfconsole -q -x 'exit'"
Benchmark 1: bundle exec ruby ./msfconsole -q -x 'exit'
Time (mean ± σ): 4.393 s ± 0.066 s [User: 3.095 s, System: 1.362 s]
Range (min … max): 4.284 s … 4.483 s 10 runs
After
Environment
AI Usage Disclosure
Kiro
Pre-Submission Checklist