-
Notifications
You must be signed in to change notification settings - Fork 1k
Initial commit of lit-labs/compiler #3984
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
Conversation
🦋 Changeset detectedLatest commit: 84b68eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen 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 |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
feb15a9 to
eb830d7
Compare
Current method is just to import all the Part constructors if any of them are needed. But an identifier that already exists breaks tests. As a stopgap have named them with an unlikely prefix.
lit-html test suite now passes!
After building, run benchmark with: `npm run benchmark:lit-html:kitchen-sink-compiled -w @lit-internal/benchmarks`
Found one test where stripping the expression markers broke the test between compiled and uncompiled. If that's a problem we may need to emit a fake marker, e.g. lit$1$, to prevent test breakages.
eb830d7 to
c98cb43
Compare
Otherwise each compiler change requires a lot of string replacement in the expected result. Now it's quick to regenerate goldens and observe the output.
This is so that the code is not just 2 giant function closures.
|
This prototype was incrementally improved and landed. See all the linked PRs. |
Issue: #189
RFC: lit/rfcs#21
lit-labs/compiler
This commit adds a first (and rough) iteration of the Lit compiler for pre-compiling html TTLs. This change passes almost all lit-html tests.
The skipped tests are:
cachedirective depends on a template string array & needs handling added for compiled templates.This initial change was used for benchmarking the possible benefits of the compiler.
No changeset is included because the package is marked private and will not be released.
Why
lit-html is very fast, but if you're already using a build step there are opportunities to squeeze more performance out. By pre-compiling templates, we can skip the prepare phase of lit-html rendering.
Benchmarks
The below benchmarks can be run by checking out this branch, building the monorepo and running individual benchmarks e.g.,
npm run benchmark:lit-html:template-heavy-compiled -w @lit-internal/benchmarks.Kitchen sink average tachometer benchmark results:
render-compiled: 7.93ms - 8.10ms,render-uncompiled: 8.50ms - 8.69msupdate-compiled: 17.92ms - 18.56ms,update-uncompiled: 18.08ms - 19.00msnop-update-compiled: 5.53ms - 5.66ms,nop-update-uncompiled: 5.64ms - 5.80msTemplate Heavy average tachometer benchmark results:
render-compiled: 9.51ms - 9.67ms,render-uncompiled: 17.66ms - 18.03msupdate-compiled: 26.40 - 26.91ms,update-uncompiled: 33.62 - 34.51msrepeat average tachometer benchmark results:
render-compiled: 7.40ms - 7.62ms,render-uncompiled: 8.56ms - 8.94msupdate-compiled: 189.57ms - 197.54ms,update-uncompiled: 206.51ms - 218.68msTODO: