Skip to content

[ssr] Initial implementation of serverUntil & ServerController#1690

Draft
kevinpschaaf wants to merge 4 commits intomainfrom
lit-next-ssr-pause
Draft

[ssr] Initial implementation of serverUntil & ServerController#1690
kevinpschaaf wants to merge 4 commits intomainfrom
lit-next-ssr-pause

Conversation

@kevinpschaaf
Copy link
Member

@kevinpschaaf kevinpschaaf commented Mar 23, 2021

Adds support for opt-in asynchronous rendering (rendering a partial template and pausing until an async condition is fulfilled, and then continuing).

Implemented by adding support for special conditions during SSR rendering to return a Promise containing a continuation iterable back up to the stream, and a special readableFrom(iterable: Iterable<string>, handleAsync = false) helper that creates a Readable that handles the continuation. This allows us to keep the main rendering via a synchronous iterable (so that when not using async rendering we can preserve the ability to synchronously render lit templates), with opt-in support for async chunking.

Experimental helpers to pause rendering:

  • serverUntil - a version of the until directive that will pause rendering until the awaited promise resolves
  • ServerController - a ReactiveController interface that adds a serverUpdateComplete field/getter; when implemented and returns a promise, rendering will be paused until the/all controllers have resolved

If the helpers aren't used, Readable.from(render(...)) will continue to work. If code being rendered does use one of the helpers, the readable should be created with readableFrom(render(...), true), otherwise Readable.from will throw.

@google-cla google-cla bot added the cla: yes label Mar 23, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Mar 23, 2021

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -2% - +5% (-0.96ms - +1.93ms)
    this-change vs tip-of-tree

render

  • lit-element-list: unsure 🔍 -2% - +1% (-2.73ms - +1.47ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -3% - +2% (-1.38ms - +1.01ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -1% - +3% (-0.20ms - +0.39ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -4% - +1% (-3.08ms - +0.61ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -2% - +1% (-1.78ms - +0.55ms)
    this-change vs tip-of-tree

update

  • lit-element-list: unsure 🔍 -1% - +1% (-4.64ms - +9.40ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -3% - +3% (-3.14ms - +4.05ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -1% - +1% (-3.48ms - +6.17ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -1% - +2% (-2.08ms - +2.85ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +0% (-12.18ms - +1.85ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: unsure 🔍 -1% - +0% (-10.90ms - +2.99ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +0% (-13.15ms - +2.54ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
107.54ms - 110.02ms-unsure 🔍
-2% - +1%
-2.73ms - +1.47ms
faster ✔
20% - 23%
27.41ms - 31.48ms
tip-of-tree
tip-of-tree
107.72ms - 111.11msunsure 🔍
-1% - +3%
-1.47ms - +2.73ms
-faster ✔
19% - 22%
26.48ms - 31.15ms
previous-release
previous-release
136.62ms - 139.84msslower ❌
25% - 29%
27.41ms - 31.48ms
slower ❌
24% - 29%
26.48ms - 31.15ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
925.49ms - 935.14ms-unsure 🔍
-1% - +1%
-4.64ms - +9.40ms
faster ✔
7% - 9%
72.59ms - 86.72ms
tip-of-tree
tip-of-tree
922.83ms - 933.03msunsure 🔍
-1% - +0%
-9.40ms - +4.64ms
-faster ✔
7% - 9%
74.78ms - 89.29ms
previous-release
previous-release
1004.80ms - 1015.13msslower ❌
8% - 9%
72.59ms - 86.72ms
slower ❌
8% - 10%
74.78ms - 89.29ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1000.23ms - 1009.40ms-unsure 🔍
-1% - +0%
-10.90ms - +2.99ms
faster ✔
4% - 5%
42.26ms - 56.83ms
tip-of-tree
tip-of-tree
1003.55ms - 1013.99msunsure 🔍
-0% - +1%
-2.99ms - +10.90ms
-faster ✔
4% - 5%
37.89ms - 53.29ms
previous-release
previous-release
1048.70ms - 1060.02msslower ❌
4% - 6%
42.26ms - 56.83ms
slower ❌
4% - 5%
37.89ms - 53.29ms
-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
45.20ms - 46.31ms-unsure 🔍
-3% - +2%
-1.38ms - +1.01ms
faster ✔
14% - 17%
7.51ms - 9.43ms
tip-of-tree
tip-of-tree
44.89ms - 47.00msunsure 🔍
-2% - +3%
-1.01ms - +1.38ms
-faster ✔
13% - 18%
6.97ms - 9.60ms
previous-release
previous-release
53.44ms - 55.01msslower ❌
16% - 21%
7.51ms - 9.43ms
slower ❌
15% - 21%
6.97ms - 9.60ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
118.88ms - 123.98ms-unsure 🔍
-3% - +3%
-3.14ms - +4.05ms
slower ❌
0% - 6%
0.09ms - 7.42ms
tip-of-tree
tip-of-tree
118.45ms - 123.50msunsure 🔍
-3% - +3%
-4.05ms - +3.14ms
-unsure 🔍
-0% - +6%
-0.34ms - +6.95ms
previous-release
previous-release
115.05ms - 120.30msfaster ✔
0% - 6%
0.09ms - 7.42ms
unsure 🔍
-6% - +0%
-6.95ms - +0.34ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
38.73ms - 41.00ms-unsure 🔍
-2% - +5%
-0.96ms - +1.93ms
unsure 🔍
-6% - +2%
-2.49ms - +1.00ms
tip-of-tree
tip-of-tree
38.49ms - 40.27msunsure 🔍
-5% - +2%
-1.93ms - +0.96ms
-unsure 🔍
-7% - +1%
-2.82ms - +0.37ms
previous-release
previous-release
39.29ms - 41.94msunsure 🔍
-3% - +6%
-1.00ms - +2.49ms
unsure 🔍
-1% - +7%
-0.37ms - +2.82ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
14.36ms - 14.89ms-unsure 🔍
-1% - +3%
-0.20ms - +0.39ms
faster ✔
13% - 17%
2.13ms - 2.88ms
tip-of-tree
tip-of-tree
14.39ms - 14.66msunsure 🔍
-3% - +1%
-0.39ms - +0.20ms
-faster ✔
14% - 17%
2.31ms - 2.90ms
previous-release
previous-release
16.87ms - 17.39msslower ❌
14% - 20%
2.13ms - 2.88ms
slower ❌
16% - 20%
2.31ms - 2.90ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
437.10ms - 443.26ms-unsure 🔍
-1% - +1%
-3.48ms - +6.17ms
faster ✔
27% - 29%
162.74ms - 178.44ms
tip-of-tree
tip-of-tree
435.12ms - 442.56msunsure 🔍
-1% - +1%
-6.17ms - +3.48ms
-faster ✔
27% - 29%
163.81ms - 180.06ms
previous-release
previous-release
603.55ms - 618.00msslower ❌
37% - 41%
162.74ms - 178.44ms
slower ❌
37% - 41%
163.81ms - 180.06ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
70.97ms - 72.22ms-unsure 🔍
-4% - +1%
-3.08ms - +0.61ms
faster ✔
21% - 24%
19.27ms - 22.27ms
tip-of-tree
tip-of-tree
71.10ms - 74.57msunsure 🔍
-1% - +4%
-0.61ms - +3.08ms
-faster ✔
19% - 23%
17.32ms - 21.74ms
previous-release
previous-release
91.00ms - 93.73msslower ❌
27% - 31%
19.27ms - 22.27ms
slower ❌
23% - 30%
17.32ms - 21.74ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
152.56ms - 156.67ms-unsure 🔍
-1% - +2%
-2.08ms - +2.85ms
faster ✔
16% - 19%
29.78ms - 35.21ms
tip-of-tree
tip-of-tree
152.88ms - 155.59msunsure 🔍
-2% - +1%
-2.85ms - +2.08ms
-faster ✔
17% - 19%
30.65ms - 35.12ms
previous-release
previous-release
185.34ms - 188.89msslower ❌
19% - 23%
29.78ms - 35.21ms
slower ❌
20% - 23%
30.65ms - 35.12ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
71.77ms - 72.94ms-unsure 🔍
-2% - +1%
-1.78ms - +0.55ms
unsure 🔍
-3% - +0%
-2.27ms - +0.34ms
tip-of-tree
tip-of-tree
71.97ms - 73.98msunsure 🔍
-1% - +2%
-0.55ms - +1.78ms
-unsure 🔍
-3% - +2%
-1.89ms - +1.19ms
previous-release
previous-release
72.16ms - 74.49msunsure 🔍
-0% - +3%
-0.34ms - +2.27ms
unsure 🔍
-2% - +3%
-1.19ms - +1.89ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
951.85ms - 962.47ms-unsure 🔍
-1% - +0%
-12.18ms - +1.85ms
unsure 🔍
-1% - +1%
-8.15ms - +6.81ms
tip-of-tree
tip-of-tree
957.74ms - 966.90msunsure 🔍
-0% - +1%
-1.85ms - +12.18ms
-unsure 🔍
-0% - +1%
-2.49ms - +11.47ms
previous-release
previous-release
952.56ms - 963.09msunsure 🔍
-1% - +1%
-6.81ms - +8.15ms
unsure 🔍
-1% - +0%
-11.47ms - +2.49ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1063.62ms - 1073.38ms-unsure 🔍
-1% - +0%
-13.15ms - +2.54ms
unsure 🔍
-1% - +1%
-10.72ms - +5.66ms
tip-of-tree
tip-of-tree
1067.67ms - 1079.95msunsure 🔍
-0% - +1%
-2.54ms - +13.15ms
-unsure 🔍
-1% - +1%
-6.22ms - +11.77ms
previous-release
previous-release
1064.45ms - 1077.60msunsure 🔍
-1% - +1%
-5.66ms - +10.72ms
unsure 🔍
-1% - +1%
-11.77ms - +6.22ms
-

tachometer-reporter-action v2 for Benchmarks

@kevinpschaaf kevinpschaaf force-pushed the lit-next-ssr-labs-client branch from c5e10e4 to 386a079 Compare March 23, 2021 17:27
Base automatically changed from lit-next-ssr-labs-client to lit-next March 31, 2021 17:14
@changeset-bot
Copy link

changeset-bot bot commented Jun 26, 2021

⚠️ No Changeset found

Latest commit: e8cc7a4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

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

Click here to learn what changesets are, and how to add one.

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

@github-actions
Copy link
Contributor

github-actions bot commented Jun 26, 2021

📊 Tachometer Benchmark Results

Summary

  • lit-element-list
  • lit-html-kitchen-sink
  • lit-html-repeat
  • lit-html-template-heavy
  • reactive-element-list

Results

tachometer-reporter-action v2 for Benchmarks

@aomarks aomarks changed the title [labs/ssr] Initial implementation of serverUntil & ServerController [ssr] Initial implementation of serverUntil & ServerController Jan 19, 2022
PonomareVlad added a commit to PonomareVlad/lit that referenced this pull request Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant