puppetlabs/puppet — pull request #2521 by keymone (2014-04-09 12:53:12+00:00)
Title: add caching to autoload

needs thorough review from more experienced puppet committers

i see 25% speed improvement when using puppet in --onetime mode

server and long-running agents might not benefit as much and potentially can have problems picking up new directories - i didn't test those use-cases yet

- cache is implemented as per-environment-name class-level instance variable `@search_directories`
- it is enabled only after puppet finishes initialization(code stolen from module_directories method)
- cache is reset when `#reload_changed` is called
- tests need occasional reset calls when they change `module_directories` or `LOAD_PATH` - which i suppose in real world only happens during initialization stage