Skip to content
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

Adaptation of @tsing80’s node joining merge tree #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stefanpenner
Copy link
Contributor

@stefanpenner stefanpenner commented Apr 24, 2016

  • merge with semver aware protocol
  • flatten only if overrides option is the same
  • deep flatten
  • flatten annotations
  • tests
  • re-generate graph

takes:

out2

and makes it:

out10

this particular test has to much noise to verify the performance characteristics. I'll try to clean it up yet.


this checks in at about a 10-15% total build time improvement

index.js Outdated
@@ -38,6 +40,28 @@ function BroccoliMergeTrees(inputNodes, options) {
this._currentTree = FSTree.fromPaths([]);
}

function joinNodes(host, options, inputNodes) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs unit test

@joliss
Copy link
Member

joliss commented Feb 22, 2017

How badly do we still want this change? While the graph after applying this change looks visually simpler, I wonder if it might actually be harder to follow.

Merging trees could be extremely cheap in an ideal world, so I would perhaps hope that the need for this might go away as we apply more and more FSTree optimizations.

@stefanpenner
Copy link
Contributor Author

@rwjblue we should chat about this, I know you have a wrapper that does this. Should be upstream?

index.js Outdated
function BroccoliMergeTrees(inputNodes, options) {
if (!(this instanceof BroccoliMergeTrees)) return new BroccoliMergeTrees(inputNodes, options)
options = options || {}
var name = 'broccoli-merge-trees:' + (options.annotation || '')
if (!Array.isArray(inputNodes)) {
throw new TypeError(name + ': Expected array, got: [' + inputNodes +']')
}
Plugin.call(this, inputNodes, {
Plugin.call(this, joinNodes(this, options, inputNodes), {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flattenNodes

index.js Outdated
@@ -15,21 +15,23 @@ function unlinkOrRmrfSync(path) {
rimraf.sync(path);
}
}
var ASSIMILATION_SYMBOL = 'broccoli-merge-tree@1.0.0';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be semver, a seperate ASSIMILATION protocol versions is likely best. Allowing for multiple version collapses..

——

Given an array of inputNodes, this function will attempt to inline all
compatible MergeTree inputNodes (recursively) with the current MergeTree

A child inputTree is considered inline safe it it:
  * has a matching options.overwrite
  * shares the same ASSIMILATION_PROTOCOL_VERSION

This function will also drop obvious duplicates.
@RuslanZavacky
Copy link

@stefanpenner curious if this PR can be ressurected? What we've noticed in our monorepo, which has a lot of packages/apps, is that mergeTrees takes up to 60% of time to process, as well as 30% of time we spent on GCs from V8.

Screenshot 2022-01-26 at 12 10 18

Screenshot 2022-01-26 at 12 09 15

It seems like walkSync / mergeDirectories takes a lot of time.

Also, as a side question - is there a possibility to minimize how much fs operations we do when we do merge? Eg. looking for the approach from fast-glob - https://github.com/nodelib/nodelib/blob/master/packages/fs/fs.scandir/README.md#old-and-modern-mode, maybe it is possible to switch to something like that?

I am happy to dig around, but before doing that I'd appreciate if it will be possible to have a chat and gain some insights, what were the original problems and cases to look at :) eg. some windows sheneningans, or some other edge-cases where specifically covered in current implementation?

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants