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

Reduce memory pressure from compat layer by disabling Heimdall node gathering during OneShotPlugin #915

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

rwjblue
Copy link
Collaborator

@rwjblue rwjblue commented Jul 30, 2021

This reduces the amount of memory that these one-shot's create by:

  • Avoiding creating Heimdall nodes for each broccoli plugin
  • For manually created heimdall nodes (e.g. ones made by individual broccoli plugins) remove any child nodes added during the one-shot process

Additionally, this makes broccoli instrumentation output quite a bit nicer for these OneShot instances (adding the addon name as an annotation). Now (with these changes) debugging which OneShot is particularly slow, is much easier...

@rwjblue rwjblue force-pushed the disable-heimdall-gathering-for-one-shots branch 2 times, most recently from 6bf3dc4 to 6ee6651 Compare July 30, 2021 22:14
@rwjblue rwjblue changed the title Disable Heimdall node gathering **during** OneShotPlugin Disable Heimdall node gathering during OneShotPlugin Jul 30, 2021
@rwjblue rwjblue added the enhancement New feature or request label Jul 30, 2021
@rwjblue rwjblue changed the title Disable Heimdall node gathering during OneShotPlugin Reduce memory pressure from compat layer by disabling Heimdall node gathering during OneShotPlugin Jul 30, 2021
Comment on lines +1 to +3
declare module 'heimdalljs' {
export default any
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is bad and I feel bad. We should fix the types publishing of [email protected] if we actually want good types here.

I'm not sure I want to shave that particular yak at the moment...

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, the existence of OneShot also seems bad and I feel bad. 😅

Do you have any sense for whether BROCOLLI_ENABLED_MEMOIZE is going to get widely enabled? It would let us drop OneShot.

We could also profile how much OneShot is really saving us on rebuilds. I think it mattered when I added it, but a lot has changed since then.

Copy link
Collaborator Author

@rwjblue rwjblue Aug 2, 2021

Choose a reason for hiding this comment

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

Do you have any sense for whether BROCOLLI_ENABLED_MEMOIZE is going to get widely enabled? It would let us drop OneShot.

The main problem is that we need to provide a reasonable escape hatch that isn't "restart the server". @stefanpenner and I have chatted about a few options, I think that the best one was to add a way to trigger a full rebuild (e.g. ignoring the memoization for that specific rebuild). The two ways we thought of doing that were something like touch tmp/perform-full-rebuild (just touch some file that we could monitor) or sending a signal to the running process (e.g. SIGUSR1) that would force it to full rebuild.

We could also profile how much OneShot is really saving us on rebuilds. I think it mattered when I added it, but a lot has changed since then.

I suspect it still saves us quite a bit of time, and will until we start moving the needle on usage of @embroider/addon-shim. But you are totally right, we should profile to see impact (both memory and build time for full builds and rebuilds).

@rwjblue rwjblue force-pushed the disable-heimdall-gathering-for-one-shots branch 2 times, most recently from d9b6c44 to 1f7916b Compare July 30, 2021 22:52
current Broccoli builder's heimdall node graph (e.g. the one that is calling
OneShotPlugin; **not** the one that the OneShotPlugin internally creates).
*/
oneshotHeimdallNode.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

we should allow you to disable this based on addon name if you want to see detail

// Make a heimdall node so that we know for sure, all nodes created during our
// inner builder can be remove easily
const oneshotCookie = heimdall.start({
name: `@embroider/compat: OneShot (${this.addonName})`,
Copy link
Contributor

Choose a reason for hiding this comment

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

OneShot will already be the name of this broccoli-plugin this will look like OneShot > @embroider/compat: OneShot addonName

This reduces the amount of memory that these one-shot's create by:

    - Avoiding creating Heimdall nodes for each broccoli plugin
    - Disabling the "re-parenting" process done by Broccoli builder
      (which ends up creating **double** the heimdall nodes)
    - For manually created heimdall nodes (e.g. ones made by individual
      broccoli plugins) remove any child nodes added during the one-shot
      process

---

Additionally, this makes broccoli instrumentation output quite a bit
nicer for these `OneShot` instances (adding the addon name as an
annotation). Now (with these changes) debugging _which_ OneShot is
particularly slow, is much easier...

Co-authored-by: Kris Selden <[email protected]>
@rwjblue rwjblue force-pushed the disable-heimdall-gathering-for-one-shots branch from 1f7916b to 6db5bc7 Compare August 2, 2021 21:04
@rwjblue rwjblue marked this pull request as ready for review August 2, 2021 21:20
@rwjblue rwjblue merged commit c9a8f48 into master Aug 3, 2021
@rwjblue rwjblue deleted the disable-heimdall-gathering-for-one-shots branch August 3, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants