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

feat: add $inspect.trace rune #14290

Draft
wants to merge 35 commits into
base: main
Choose a base branch
from
Draft

feat: add $inspect.trace rune #14290

wants to merge 35 commits into from

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Nov 13, 2024

Closes #14265. This adds the $inspect.trace rune to Svelte which logs the reactive graph of the current reactive context. It must be placed in a block statement and requires a string passed as an argument which is the trace name.

Copy link

changeset-bot bot commented Nov 13, 2024

🦋 Changeset detected

Latest commit: c3428fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@14290

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP

WIP
@Rich-Harris
Copy link
Member

preview: https://svelte-dev-git-preview-svelte-14290-svelte.vercel.app/

this is an automated message

@trueadm trueadm marked this pull request as draft November 14, 2024 20:12
@trueadm trueadm changed the title WIP: add dev time tracing feat: add dev time reactive graph tracing Nov 14, 2024
@Ocean-OS
Copy link
Contributor

Perhaps instead of having it compile to this:

$.user_effect(()=>{
return $.trace(()=>stuff, "name")
});

It could instead use a $.trace_effect (and $.trace_pre_effect) function that took an effect function and the trace name as arguments, and then:

  1. The $.trace_effect function runs the effect to get the dependencies from the effect
  2. The function destroys the effect
  3. The function creates a new effect with the trace logging
    This new effect would not need to be run initially for dependency tracking, as the dependencies have already been found. Instead, the effect could just be added to the dependencies' reactions.

And then the code could instead compile to:

$.trace_effect(()=>stuff, "name");

I'm not sure how this will change in terms of performance (which shouldn't matter too much since its only running in dev mode), but it should result in less and simpler code.

@trueadm
Copy link
Contributor Author

trueadm commented Nov 18, 2024

Perhaps instead of having it compile to this:

$.user_effect(()=>{
return $.trace(()=>stuff, "name")
});

This PR has compiled to that output for a while now. Worth checking it out again sometime :)

I'm not sure how this will change in terms of performance (which shouldn't matter too much since its only running in dev mode), but it should result in less and simpler code.

It wouldn't make anything simpler with the new design.

@trueadm
Copy link
Contributor Author

trueadm commented Nov 21, 2024

@Rich-Harris Feel free to apply your local changes to this PR if that's easier.

@trueadm trueadm changed the title feat: add dev time reactive graph tracing feat: add $inspect.trace rune Dec 5, 2024
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.

Debug symbols for dependencies of user effects/deriveds
3 participants