New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid creating extraneous merge-trees. #6453
Conversation
nice! @rwjblue may complement this nicely broccolijs/broccoli-merge-trees#43 (collapsing merge of merge) |
@homu r+ |
📌 Commit 380c2ec has been approved by |
Avoid creating extraneous merge-trees. This change does three main things: * Ensure that we always use `lib/broccoli/merge-trees.js` over requiring `broccoli-merge-trees` directly. * When `lib/broccoli/merge-trees.js` is called with a single input tree, simply return it (instead of creating a `broccoli-merge-tree` instance). * When `mergeTrees` is called with an empty array, use a single `EMPTY_MERGE_TREES` constant instance for all invocations. This prevents us from creating many useless operations to essentially support an "empty" tree. It is possible that we might want to teach Broccoli itself about empty trees, but that is left as a future excercise. The results of these changes even in a newly created empty app are fairly significant. Here are the counts of `tmp` directories created before and after: * 952 - Before changes * 316 - After changes In a real app, these numbers would be even higher (due to addons at each level of nesting). --- Credit goes to @stefanpenner for the idea and initial implementation (which was stolen from #6429).
options.description = options.annotation; | ||
var tree = upstreamMergeTrees(inputTree, options); | ||
module.exports = function mergeTrees(_inputTrees, options) { | ||
var inputTrees = _inputTrees.filter(Boolean); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we may also want to filter out other EmptyMergeTrees here.
options = options || {}; | ||
options.description = options.annotation; | ||
var tree = upstreamMergeTrees(inputTree, options); | ||
module.exports = function mergeTrees(_inputTrees, options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should likely test this guy.
@homu r- |
☀️ Test successful - status |
@stefanpenner - Updated with tests and better filtering when input array contains the |
cdf7cb8
to
332c720
Compare
@homu r+ |
📌 Commit 332c720 has been approved by |
Avoid creating extraneous merge-trees. This change does three main things: * Ensure that we always use `lib/broccoli/merge-trees.js` over requiring `broccoli-merge-trees` directly. * When `lib/broccoli/merge-trees.js` is called with a single input tree, simply return it (instead of creating a `broccoli-merge-tree` instance). * When `mergeTrees` is called with an empty array, use a single `EMPTY_MERGE_TREES` constant instance for all invocations. This prevents us from creating many useless operations to essentially support an "empty" tree. It is possible that we might want to teach Broccoli itself about empty trees, but that is left as a future excercise. The results of these changes even in a newly created empty app are fairly significant. Here are the counts of `tmp` directories created before and after: * 952 - Before changes * 274 - After changes In a real app, these numbers would be even higher (due to addons at each level of nesting). --- Credit goes to @stefanpenner for the idea and initial implementation (which was stolen from #6429).
☀️ Test successful - status |
Tested this in Ghost, the tmp dirs created during |
This change does three main things:
lib/broccoli/merge-trees.js
over requiringbroccoli-merge-trees
directly.lib/broccoli/merge-trees.js
is called with a single input tree, simply return it (instead of creating abroccoli-merge-tree
instance).mergeTrees
is called with an empty array, use a singleEMPTY_MERGE_TREES
constant instance for all invocations. This prevents us from creating many useless operations to essentially support an "empty" tree. It is possible that we might want to teach Broccoli itself about empty trees, but that is left as a future excercise.The results of these changes even in a newly created empty app are fairly significant. Here are the counts of
tmp
directories created before and after:In a real app, these numbers would be even higher (due to addons at each level of nesting).
Credit goes to @stefanpenner for the idea and initial implementation (which was stolen from #6429).