Skip to content

refactor(core): implement experimental getSignalGraph debug API #57074

Closed
AleksanderBodurri wants to merge 1 commit intoangular:mainfrom
AleksanderBodurri:get-signal-graph
Closed

refactor(core): implement experimental getSignalGraph debug API #57074
AleksanderBodurri wants to merge 1 commit intoangular:mainfrom
AleksanderBodurri:get-signal-graph

Conversation

@AleksanderBodurri
Copy link
Copy Markdown
Member

@AleksanderBodurri AleksanderBodurri commented Jul 22, 2024

Depends on #57073

Creates a debug api that returns an arrays of nodes and edges that represents a signal graph in the context of a particular injector.

Starts by discovering the consumer nodes for each injector, and then traverses their dependencies to discover each producer.

@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Jul 22, 2024
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels Jul 22, 2024
@ngbot ngbot bot added this to the Backlog milestone Jul 22, 2024
@AleksanderBodurri AleksanderBodurri requested review from dgp1130 and removed request for Jesse-Good, crisbeto and thePunderWoman July 22, 2024 06:44
Copy link
Copy Markdown
Contributor

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together! I really like the approach you came up with here and how it uses a Map. I have a number of small readability suggestions, but the main thing is probably to make sure we're fully defining and thinking through the nodes and edges data structure we're creating here.

Comment thread packages/core/src/render3/debug/framework_injector_profiler.ts Outdated
Comment thread packages/core/src/render3/debug/injector_profiler.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/test/acceptance/discover_utils_spec.ts Outdated
Comment thread packages/core/test/acceptance/discover_utils_spec.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/debug/framework_injector_profiler.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
assertLView(lView);
const templateLView = lView[tNode.index];
if (templateLView) {
const templateConsumer = templateLView[REACTIVE_TEMPLATE_CONSUMER];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Per @alxhub, there may be multiple template consumers for a component (one per view), so we need to keep those as well.

It seems that for the current moment we generally only use a single template effect per-component, but a template effect per-view is the direction we'd like to move for signal components and want to make sure DevTools is compatible with that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alxhub, we discussed this issues a little while back, but it seems like Angular still uses only one consumer per component as we don't yet have different consumers per-view? @AleksanderBodurri and I were thinking it would make sense to stick with the current implementation for now and maybe revisit the one-consumer-per-view issue as we get closer to true @Component({ signal: true })? Is that the right approach or is there more we can/should do today in this space?

Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Sep 24, 2024
Copy link
Copy Markdown
Contributor

@dgp1130 dgp1130 left a comment

Choose a reason for hiding this comment

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

This is looking great @AleksanderBodurri! I don't have any major concerns, just a handful of readability improvements and some file suggestions.

I'll defer to @alxhub and other FW folks on the nuances of DI usage though.

Comment thread packages/core/src/render3/debug/framework_injector_profiler.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/test/acceptance/discover_utils_spec.ts Outdated
Comment thread packages/core/src/render3/util/discovery_utils.ts Outdated
assertLView(lView);
const templateLView = lView[tNode.index];
if (templateLView) {
const templateConsumer = templateLView[REACTIVE_TEMPLATE_CONSUMER];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@alxhub, we discussed this issues a little while back, but it seems like Angular still uses only one consumer per component as we don't yet have different consumers per-view? @AleksanderBodurri and I were thinking it would make sense to stick with the current implementation for now and maybe revisit the one-consumer-per-view issue as we get closer to true @Component({ signal: true })? Is that the right approach or is there more we can/should do today in this space?

Comment thread packages/core/test/acceptance/discover_utils_spec.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
Comment thread packages/core/src/render3/util/signal_debug.ts Outdated
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 21, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 22, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 22, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 23, 2024
@pullapprove pullapprove bot added the requires: TGP This PR requires a passing TGP before merging is allowed label Oct 23, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 23, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 23, 2024
@angular-robot angular-robot bot added area: core Issues related to the framework runtime and removed area: core Issues related to the framework runtime labels Oct 23, 2024
@ngbot ngbot bot modified the milestone: Backlog Oct 23, 2024
@angular-robot angular-robot bot removed the area: core Issues related to the framework runtime label Oct 23, 2024
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Does this require a separate PR since it's in core/primitives? @alxhub

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes it would. Let's do this step as a cleanup maybe? We can rely on the property sniffing for now.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, removed the modification to this file and implemented property sniffing approach temporarily.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes it would. Let's do this step as a cleanup maybe? We can rely on the property sniffing for now.

Creates a debug api that returns an arrays of nodes and edges that represents a signal graph in the context of a particular injector.

Starts by discovering the consumer nodes for each injector, and then traverses their dependencies to discover each producer.
@dgp1130
Copy link
Copy Markdown
Contributor

dgp1130 commented Dec 10, 2024

CARETAKER NOTE: g3 tests are passing with a single flake which can be ignored.

http://test/OCL:704492061:BASE:704783405:1733858591915:66403176

@ngbot
Copy link
Copy Markdown

ngbot bot commented Dec 10, 2024

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@alxhub
Copy link
Copy Markdown
Member

alxhub commented Dec 10, 2024

This PR was merged into the repository by commit 33167d9.

The changes were merged into the following branches: main

@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants