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

Add @lit-labs/signals package #4615

Merged
merged 22 commits into from
Oct 3, 2024
Merged

Add @lit-labs/signals package #4615

merged 22 commits into from
Oct 3, 2024

Conversation

justinfagnani
Copy link
Collaborator

WIP: Still some rough edges with trying to sync watch() updates and regular updates.

Copy link

changeset-bot bot commented Apr 10, 2024

🦋 Changeset detected

Latest commit: 52dd697

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

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

github-actions bot commented Apr 10, 2024

📊 Tachometer Benchmark Results

Summary

nop-update

  • this-change, tip-of-tree, previous-release: unsure 🔍 -6% - +11% (-0.81ms - +1.39ms)
    this-change vs tip-of-tree

render

  • this-change: 46.64ms - 55.96ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -5% - +3% (-0.97ms - +0.52ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +2% (-0.90ms - +0.76ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: faster ✔ 4% - 43% (0.81ms - 31.93ms)
    this-change vs tip-of-tree

update

  • this-change: 513.58ms - 517.31ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -4% - +5% (-1.57ms - +1.92ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +3% (-1.30ms - +1.92ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +2% (-10.79ms - +9.59ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 511.91ms - 517.67ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +0% (-9.88ms - +1.65ms)
    this-change vs tip-of-tree

Results

this-change

render

VersionAvg timevs
46.64ms - 55.96ms-

update

VersionAvg timevs
513.58ms - 517.31ms-

update-reflect

VersionAvg timevs
511.91ms - 517.67ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
19.35ms - 20.32ms-unsure 🔍
-5% - +3%
-0.97ms - +0.52ms
unsure 🔍
-4% - +2%
-0.79ms - +0.48ms
tip-of-tree
tip-of-tree
19.49ms - 20.62msunsure 🔍
-3% - +5%
-0.52ms - +0.97ms
-unsure 🔍
-3% - +4%
-0.63ms - +0.77ms
previous-release
previous-release
19.57ms - 20.40msunsure 🔍
-2% - +4%
-0.48ms - +0.79ms
unsure 🔍
-4% - +3%
-0.77ms - +0.63ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
39.11ms - 41.20ms-unsure 🔍
-4% - +5%
-1.57ms - +1.92ms
unsure 🔍
-5% - +2%
-2.00ms - +0.93ms
tip-of-tree
tip-of-tree
38.59ms - 41.37msunsure 🔍
-5% - +4%
-1.92ms - +1.57ms
-unsure 🔍
-6% - +2%
-2.44ms - +1.02ms
previous-release
previous-release
39.66ms - 41.72msunsure 🔍
-2% - +5%
-0.93ms - +2.00ms
unsure 🔍
-3% - +6%
-1.02ms - +2.44ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
12.53ms - 13.97ms-unsure 🔍
-6% - +11%
-0.81ms - +1.39ms
unsure 🔍
-10% - +6%
-1.38ms - +0.79ms
tip-of-tree
tip-of-tree
12.13ms - 13.79msunsure 🔍
-10% - +6%
-1.39ms - +0.81ms
-unsure 🔍
-13% - +4%
-1.74ms - +0.58ms
previous-release
previous-release
12.73ms - 14.35msunsure 🔍
-6% - +10%
-0.79ms - +1.38ms
unsure 🔍
-5% - +14%
-0.58ms - +1.74ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
35.70ms - 36.50ms-unsure 🔍
-2% - +2%
-0.90ms - +0.76ms
unsure 🔍
-1% - +2%
-0.24ms - +0.77ms
tip-of-tree
tip-of-tree
35.45ms - 36.89msunsure 🔍
-2% - +2%
-0.76ms - +0.90ms
-unsure 🔍
-1% - +3%
-0.46ms - +1.12ms
previous-release
previous-release
35.53ms - 36.15msunsure 🔍
-2% - +1%
-0.77ms - +0.24ms
unsure 🔍
-3% - +1%
-1.12ms - +0.46ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
73.38ms - 75.83ms-unsure 🔍
-2% - +3%
-1.30ms - +1.92ms
unsure 🔍
-1% - +3%
-0.59ms - +2.52ms
tip-of-tree
tip-of-tree
73.26ms - 75.34msunsure 🔍
-3% - +2%
-1.92ms - +1.30ms
-unsure 🔍
-1% - +3%
-0.76ms - +2.07ms
previous-release
previous-release
72.68ms - 74.61msunsure 🔍
-3% - +1%
-2.52ms - +0.59ms
unsure 🔍
-3% - +1%
-2.07ms - +0.76ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
43.19ms - 63.54ms-faster ✔
4% - 43%
0.81ms - 31.93ms
unsure 🔍
-38% - +6%
-25.15ms - +5.33ms
tip-of-tree
tip-of-tree
57.97ms - 81.51msunsure 🔍
-3% - +64%
+0.81ms - +31.93ms
-unsure 🔍
-17% - +37%
-9.89ms - +22.81ms
previous-release
previous-release
51.93ms - 74.62msunsure 🔍
-12% - +50%
-5.33ms - +25.15ms
unsure 🔍
-32% - +13%
-22.81ms - +9.89ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
522.51ms - 529.32ms-unsure 🔍
-2% - +2%
-10.79ms - +9.59ms
unsure 🔍
-1% - +1%
-3.73ms - +6.57ms
tip-of-tree
tip-of-tree
516.91ms - 536.12msunsure 🔍
-2% - +2%
-9.59ms - +10.79ms
-unsure 🔍
-2% - +2%
-8.33ms - +12.37ms
previous-release
previous-release
520.64ms - 528.36msunsure 🔍
-1% - +1%
-6.57ms - +3.73ms
unsure 🔍
-2% - +2%
-12.37ms - +8.33ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
553.18ms - 557.85ms-unsure 🔍
-2% - +0%
-9.88ms - +1.65ms
unsure 🔍
-1% - +0%
-4.72ms - +2.26ms
tip-of-tree
tip-of-tree
554.36ms - 564.90msunsure 🔍
-0% - +2%
-1.65ms - +9.88ms
-unsure 🔍
-1% - +2%
-2.99ms - +8.76ms
previous-release
previous-release
554.16ms - 559.34msunsure 🔍
-0% - +1%
-2.26ms - +4.72ms
unsure 🔍
-2% - +1%
-8.76ms - +2.99ms
-

tachometer-reporter-action v2 for Benchmarks

Copy link
Contributor

github-actions bot commented Apr 10, 2024

The size of lit-html.js and lit-core.min.js are as expected.

Copy link
Member

@sorvell sorvell left a comment

Choose a reason for hiding this comment

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

For watch, let's consider @e111077 's feedback and maybe have a way to auto-wrap a function (maybe if it's not an event part?).

And I really like using the html and not manually watching but if we do that we probably want unwatched which is just basically an echoing directive.

packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/rollup.config.js Outdated Show resolved Hide resolved
packages/labs/signals/rollup.config.js Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/html-tag.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/index.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Outdated Show resolved Hide resolved
@JosefJezek
Copy link

@justinfagnani any progress?

@justinfagnani justinfagnani changed the title WIP: Add @lit-labs/signals package Add @lit-labs/signals package Jul 31, 2024
@justinfagnani justinfagnani marked this pull request as ready for review July 31, 2024 20:20
@justinfagnani
Copy link
Collaborator Author

@JosefJezek just pushed a major update. Hopefully we land this soon.

@justinfagnani
Copy link
Collaborator Author

@sorvell and @e111077 thanks for the first pass a while back! PTAL

I rewrote most of SignalWatcher and I think simplified things a lot, and I added a bunch of comments, so hopefully it's easier to follow now.

@justinfagnani
Copy link
Collaborator Author

When this is merged we'll need to create a Lit Labs page entry on lit.dev and a feedback discussion thread similar to #4115

Co-authored-by: Pascal Schilp <pascalschilp@gmail.com>
packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/src/index.ts Show resolved Hide resolved
packages/labs/signals/src/index.ts Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
@justinfagnani
Copy link
Collaborator Author

@sorvell @e111077 I implemented the manual memory management code in the last two commits, if you can review that.

I'll review the last round of comments ASAP, if there are any left unresolved.

Copy link
Contributor

@e111077 e111077 left a comment

Choose a reason for hiding this comment

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

The memory approach is clever. Wonder if we might run into issues down the line with watchers running unnecessarily because of FinalizationRegistry timing. Though only things I could think of that might run into that are users writing brittle code that is probably in need of a rewrite anyway

packages/labs/signals/LICENSE Outdated Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
@justinfagnani
Copy link
Collaborator Author

All the current test failures are from virtualizer. Re-running tests hasn't made them pass, so I'm not sure if they're flaky.

@justinfagnani
Copy link
Collaborator Author

I tried to update test dependencies in #4758 to see if that would help the virtualizer tests. That didn't work locally at least, so I'll keep re-running the test job for now.

Copy link
Collaborator Author

@justinfagnani justinfagnani left a comment

Choose a reason for hiding this comment

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

PTAL!

packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Show resolved Hide resolved
packages/labs/signals/src/lib/watch.ts Show resolved Hide resolved
@justinfagnani
Copy link
Collaborator Author

@graynorton I had to disable the virtualizer tests here because they wouldn't pass even on multiple test re-runs. This PR doesn't change any core or virtualizer code, nor does it update any relevant dependencies int he package lock. I'm not sure how to move forward there. Any advice would be helpful!

Copy link
Contributor

@e111077 e111077 left a comment

Choose a reason for hiding this comment

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

All my comments at this point are just doc nits. Code looks good to me

packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/README.md Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
packages/labs/signals/src/lib/signal-watcher.ts Outdated Show resolved Hide resolved
@justinfagnani justinfagnani merged commit a847717 into main Oct 3, 2024
10 checks passed
@justinfagnani justinfagnani deleted the lit-signals branch October 3, 2024 03:11
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.

6 participants