Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@taylor-vann
Copy link
Contributor

@taylor-vann taylor-vann commented May 5, 2022

Currently the initial value of Task is assumed to be undefined.
This is the default behavior. When a Task is "re-run", value is set as undefined.

This PR adds an initialValue to the TaskConfig interface.
When no intialValue is set, the behavior described above is preserved.

When initialValue is set, the value is only updated when the task completes. As in, the initial value will not be set in future PENDING states.

@taylor-vann taylor-vann requested a review from justinfagnani as a code owner May 5, 2022 18:30
@changeset-bot
Copy link

changeset-bot bot commented May 5, 2022

🦋 Changeset detected

Latest commit: b848485

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

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

@taylor-vann taylor-vann requested a review from sorvell May 5, 2022 18:30
@github-actions
Copy link
Contributor

github-actions bot commented May 5, 2022

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -2% - +9% (-0.62ms - +2.86ms)
    this-change vs tip-of-tree

render

  • lit-element-list: unsure 🔍 -7% - +0% (-7.66ms - +0.29ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -3% - +5% (-1.33ms - +2.24ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -7% - +2% (-0.98ms - +0.26ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -2% - +5% (-1.57ms - +3.18ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -0% - +21% (+0.03ms - +16.47ms)
    this-change vs tip-of-tree

update

  • lit-element-list: unsure 🔍 -1% - +5% (-12.88ms - +46.79ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -1% - +10% (-0.41ms - +10.62ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -9% - +6% (-32.53ms - +22.68ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -4% - +2% (-5.94ms - +3.48ms)
    this-change vs tip-of-tree
  • reactive-element-list: faster ✔ 0% - 17% (0.74ms - 298.71ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: unsure 🔍 -2% - +1% (-16.60ms - +11.90ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -3% - +1% (-38.82ms - +7.29ms)
    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
98.53ms - 103.63ms-unsure 🔍
-7% - +0%
-7.66ms - +0.29ms
faster ✔
22% - 27%
28.46ms - 37.53ms
tip-of-tree
tip-of-tree
101.72ms - 107.82msunsure 🔍
-0% - +8%
-0.29ms - +7.66ms
-faster ✔
19% - 25%
24.47ms - 34.14ms
previous-release
previous-release
130.33ms - 137.82msslower ❌
28% - 38%
28.46ms - 37.53ms
slower ❌
23% - 33%
24.47ms - 34.14ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1004.70ms - 1062.62ms-unsure 🔍
-1% - +5%
-12.88ms - +46.79ms
faster ✔
33% - 37%
515.58ms - 585.49ms
tip-of-tree
tip-of-tree
1009.53ms - 1023.89msunsure 🔍
-4% - +1%
-46.79ms - +12.88ms
-faster ✔
35% - 37%
546.64ms - 588.34ms
previous-release
previous-release
1564.62ms - 1603.77msslower ❌
49% - 58%
515.58ms - 585.49ms
slower ❌
54% - 58%
546.64ms - 588.34ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1003.49ms - 1025.09ms-unsure 🔍
-2% - +1%
-16.60ms - +11.90ms
faster ✔
8% - 10%
87.58ms - 117.91ms
tip-of-tree
tip-of-tree
1007.35ms - 1025.94msunsure 🔍
-1% - +2%
-11.90ms - +16.60ms
-faster ✔
8% - 10%
86.26ms - 114.52ms
previous-release
previous-release
1106.39ms - 1127.68msslower ❌
9% - 12%
87.58ms - 117.91ms
slower ❌
8% - 11%
86.26ms - 114.52ms
-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
41.89ms - 44.49ms-unsure 🔍
-3% - +5%
-1.33ms - +2.24ms
faster ✔
5% - 12%
2.28ms - 5.76ms
tip-of-tree
tip-of-tree
41.51ms - 43.96msunsure 🔍
-5% - +3%
-2.24ms - +1.33ms
-faster ✔
6% - 13%
2.79ms - 6.16ms
previous-release
previous-release
46.05ms - 48.37msslower ❌
5% - 14%
2.28ms - 5.76ms
slower ❌
6% - 15%
2.79ms - 6.16ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
107.66ms - 115.33ms-unsure 🔍
-1% - +10%
-0.41ms - +10.62ms
unsure 🔍
-2% - +9%
-2.15ms - +9.26ms
tip-of-tree
tip-of-tree
102.43ms - 110.35msunsure 🔍
-9% - +0%
-10.62ms - +0.41ms
-unsure 🔍
-7% - +4%
-7.34ms - +4.24ms
previous-release
previous-release
103.71ms - 112.17msunsure 🔍
-8% - +2%
-9.26ms - +2.15ms
unsure 🔍
-4% - +7%
-4.24ms - +7.34ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
32.90ms - 35.50ms-unsure 🔍
-2% - +9%
-0.62ms - +2.86ms
faster ✔
2% - 11%
0.60ms - 3.90ms
tip-of-tree
tip-of-tree
31.92ms - 34.24msunsure 🔍
-8% - +2%
-2.86ms - +0.62ms
-faster ✔
5% - 13%
1.83ms - 4.91ms
previous-release
previous-release
35.44ms - 37.46msslower ❌
2% - 12%
0.60ms - 3.90ms
slower ❌
5% - 15%
1.83ms - 4.91ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
12.52ms - 13.40ms-unsure 🔍
-7% - +2%
-0.98ms - +0.26ms
faster ✔
12% - 20%
1.77ms - 3.11ms
tip-of-tree
tip-of-tree
12.89ms - 13.76msunsure 🔍
-2% - +8%
-0.26ms - +0.98ms
-faster ✔
9% - 17%
1.41ms - 2.74ms
previous-release
previous-release
14.89ms - 15.91msslower ❌
13% - 24%
1.77ms - 3.11ms
slower ❌
10% - 21%
1.41ms - 2.74ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
349.91ms - 388.70ms-unsure 🔍
-9% - +6%
-32.53ms - +22.68ms
faster ✔
23% - 33%
115.89ms - 171.09ms
tip-of-tree
tip-of-tree
354.58ms - 393.88msunsure 🔍
-6% - +9%
-22.68ms - +32.53ms
-faster ✔
22% - 32%
110.79ms - 166.34ms
previous-release
previous-release
493.16ms - 532.43msslower ❌
30% - 48%
115.89ms - 171.09ms
slower ❌
28% - 46%
110.79ms - 166.34ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
66.63ms - 70.28ms-unsure 🔍
-2% - +5%
-1.57ms - +3.18ms
faster ✔
13% - 18%
10.44ms - 15.08ms
tip-of-tree
tip-of-tree
66.14ms - 69.16msunsure 🔍
-5% - +2%
-3.18ms - +1.57ms
-faster ✔
14% - 19%
11.48ms - 15.65ms
previous-release
previous-release
79.78ms - 82.65msslower ❌
15% - 22%
10.44ms - 15.08ms
slower ❌
17% - 23%
11.48ms - 15.65ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
144.40ms - 150.41ms-unsure 🔍
-4% - +2%
-5.94ms - +3.48ms
faster ✔
13% - 18%
22.89ms - 32.58ms
tip-of-tree
tip-of-tree
145.01ms - 152.26msunsure 🔍
-2% - +4%
-3.48ms - +5.94ms
-faster ✔
12% - 18%
21.25ms - 31.76ms
previous-release
previous-release
171.34ms - 178.94msslower ❌
15% - 22%
22.89ms - 32.58ms
slower ❌
14% - 22%
21.25ms - 31.76ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
82.01ms - 94.75ms-unsure 🔍
-0% - +21%
+0.03ms - +16.47ms
unsure 🔍
-8% - +13%
-7.12ms - +11.13ms
tip-of-tree
tip-of-tree
74.94ms - 85.34msfaster ✔
1% - 18%
0.03ms - 16.47ms
-unsure 🔍
-16% - +2%
-14.59ms - +2.11ms
previous-release
previous-release
79.84ms - 92.91msunsure 🔍
-12% - +8%
-11.13ms - +7.12ms
unsure 🔍
-3% - +19%
-2.11ms - +14.59ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1479.12ms - 1708.03ms-faster ✔
0% - 17%
0.74ms - 298.71ms
unsure 🔍
-9% - +13%
-130.85ms - +206.29ms
tip-of-tree
tip-of-tree
1647.93ms - 1838.67msunsure 🔍
-0% - +19%
+0.74ms - +298.71ms
-slower ❌
1% - 23%
31.20ms - 343.68ms
previous-release
previous-release
1432.10ms - 1679.61msunsure 🔍
-13% - +8%
-206.29ms - +130.85ms
faster ✔
2% - 19%
31.20ms - 343.68ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1097.35ms - 1129.03ms-unsure 🔍
-3% - +1%
-38.82ms - +7.29ms
unsure 🔍
-1% - +3%
-6.33ms - +35.23ms
tip-of-tree
tip-of-tree
1112.21ms - 1145.71msunsure 🔍
-1% - +4%
-7.29ms - +38.82ms
-slower ❌
1% - 5%
8.74ms - 51.70ms
previous-release
previous-release
1085.30ms - 1112.18msunsure 🔍
-3% - +1%
-35.23ms - +6.33ms
faster ✔
1% - 5%
8.74ms - 51.70ms
-

tachometer-reporter-action v2 for Benchmarks

@taylor-vann
Copy link
Contributor Author

related to: #2367

@mohe2015
Copy link

mohe2015 commented May 7, 2022

What is a concrete use case for this? I don't fully understand that yet.

@taylor-vann
Copy link
Contributor Author

taylor-vann commented May 10, 2022

@mohe2015 one potential use-case is lazy loading / lazy execution of a task, providing data for the initial render but before a remote request, a kind of Null Object for tasks that correlate to an initial render.

User loads page. Component needs a visual "stencil" up until the asynchronous task is requested / performed / completed.

@taylor-vann
Copy link
Contributor Author

addressed feedback

@taylor-vann taylor-vann requested a review from sorvell May 10, 2022 17:53
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.

Please add a test where initialValue is set.

@taylor-vann
Copy link
Contributor Author

@sorvell added a test for initial values :) ready for another review

@taylor-vann taylor-vann requested a review from sorvell May 19, 2022 17:03
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz left a comment

Choose a reason for hiding this comment

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

Please remove all the .wireit directory files.

They should have been ignored by .gitignore?

@taylor-vann
Copy link
Contributor Author

thanks @AndrewJakubowicz, theyve been removed.

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.

Almost there, just a couple of points to address, see comments. Let's also make sure to update the PR description to say that the value is only updated when the task completes (currently, it incorrectly says that it's reset to the initialValue).

assert.equal(el.taskValue, undefined);
});

test('tasks start with initialValues in the first PENDING state', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Please add another test that specifically validates the task value during the different states when it's re-run. Some of the changes here reflect the new behavior but I think it makes sense to have a test that focuses on that aspect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Member

Choose a reason for hiding this comment

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

We want specifically a test that validates that the value is not reset when the task is re-run (before it completes). This has nothing to do with initial value, but the behavior is being changed with this PR.

@AndrewJakubowicz AndrewJakubowicz self-requested a review May 20, 2022 22:10
@taylor-vann
Copy link
Contributor Author

Sweet! thanks yall
Andrew:

  • got rid of the .wireit files
  • left a more descriptive changelog
    Steve:
  • updated the description of the PR to correctly reflect behavior
  • added a test to test the described behavior: only set initialValue on first PENDING state, not after.

@taylor-vann taylor-vann requested a review from sorvell May 23, 2022 21:40
@sorvell
Copy link
Member

sorvell commented May 25, 2022

When a Task is "re-run", value is set as undefined.

This is not true is it?

---

Added `initialValue` parameter to `TaskConfig`.
Task can start with an initial value from TaskConfig.
Copy link
Member

Choose a reason for hiding this comment

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

We are changing the behavior of how value is treated when the task is re-run. This should be called out specifically here.

}
this.status = TaskStatus.PENDING;
this._error = undefined;
this._value = undefined;
Copy link
Member

Choose a reason for hiding this comment

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

This is the significant change that I want to make sure we're documenting and testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

First I think we need to decide that this is the behavior we want. Is it required to add an initial value? Should it be controlled with an option? Let's chat.

assert.equal(el.taskValue, undefined);
});

test('tasks start with initialValues in the first PENDING state', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

We want specifically a test that validates that the value is not reset when the task is re-run (before it completes). This has nothing to do with initial value, but the behavior is being changed with this PR.

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.

Technically this looks fine to me. Code LGTM

I'm also in favor of this behavior – Task has the tendency to flicker. Would be cool if value is the way to make it not

@taylor-vann
Copy link
Contributor Author

Haven't checked on this PR in a while, will update and rerequest a review. I think the tests could be better

@justinfagnani
Copy link
Collaborator

Superseded by #4001

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