Feature | lazy_load_previews_and_pages
config option
#641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, we're loving lookbook over at @buildkite.
Recently I've been doing some benchmarking of our application boot times and found that lookbook's eager loading of previews and pages in an
after_initialization
hook contributes ~250ms (~12%) to our boot time* in development, which is the only environment in which we have lookbook configured (for now at least). We have ~35 previews and ~5 pages at the time of writing, and I'm assuming that the time taken will gradually increase linearly as we add more.I'm proposing a config option to defer the loading of the preview and page data to the first time it's needed, which from scouring the code seemed to be entity lookups when hitting the lookbook routes. This is especially useful when utilising the Rails console, runner, rake tasks etc. which don't need this data to be loaded.
I used vernier to benchmark this with
bin/rails c
, you can go here and load the comparison outputs below:I also then ensured that our previews and pages load as usual when first requested, and that if a preview or page changed before any were requested, all of them are loaded on the first change with the change reflected in the UI.
Notes:
class Application
is defined to right afterRails.application.initialize!
is called i.e. it excludes requiring Rails and other gems.