Skip to content

Move child reodering to diffChildren#2813

Merged
marvinhagemeister merged 14 commits intomasterfrom
fix-next-dom
Nov 21, 2020
Merged

Move child reodering to diffChildren#2813
marvinhagemeister merged 14 commits intomasterfrom
fix-next-dom

Conversation

@JoviDeCroock
Copy link
Copy Markdown
Member

@JoviDeCroock JoviDeCroock commented Nov 1, 2020

We used to reorder within the scope of a single bailed vnode diff, we're in a better position when we are currently inside of a diffChildren to correctly hand off oldDom to the next node.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 1, 2020

📊 Tachometer Benchmark Results

Summary

duration

  • 02_replace1k: unsure 🔍 -5% - +5% (-7.60ms - +7.76ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -4% - +2% (-1.44ms - +0.63ms)
    preact-local vs preact-master
  • many_updates: unsure 🔍 -8% - +5% (-4.50ms - +2.89ms)
    preact-local vs preact-master
  • text_update: unsure 🔍 -4% - +6% (-0.13ms - +0.19ms)
    preact-local vs preact-master

window.usedJSHeapSize

  • 02_replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-master
  • 03_update10th1k_x16: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-master
  • many_updates: slower ❌ 0% - 0% (0.00ms - 0.00ms)
    preact-local vs preact-master
  • text_update: slower ❌ 0% - 0% (0.00ms - 0.00ms)
    preact-local vs preact-master

Results

02_replace1k
  • Browser: chrome-headless 86.0.4240.183
  • Sample size: 50
  • Built by: CI #501
  • Commit: 74f22d0

duration

VersionAvg timevs preact-mastervs preact-local
preact-master162.32ms - 172.67ms-unsure 🔍
-5% - +5%
-7.76ms - +7.60ms
preact-local161.90ms - 173.25msunsure 🔍
-5% - +5%
-7.60ms - +7.76ms
-

window.usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.57ms - 3.57ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-local3.57ms - 3.57msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
03_update10th1k_x16
  • Browser: chrome-headless 86.0.4240.183
  • Sample size: 50
  • Built by: CI #501
  • Commit: 74f22d0

duration

VersionAvg timevs preact-mastervs preact-local
preact-master31.57ms - 33.03ms-unsure 🔍
-2% - +5%
-0.63ms - +1.44ms
preact-local31.15ms - 32.63msunsure 🔍
-4% - +2%
-1.44ms - +0.63ms
-

window.usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master3.51ms - 3.52ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-local3.51ms - 3.52msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-
many_updates
  • Browser: chrome-headless 86.0.4240.183
  • Sample size: 70
  • Built by: CI #501
  • Commit: 74f22d0

duration

VersionAvg timevs preact-mastervs preact-local
preact-master54.29ms - 59.45ms-unsure 🔍
-5% - +8%
-2.89ms - +4.50ms
preact-local53.41ms - 58.71msunsure 🔍
-8% - +5%
-4.50ms - +2.89ms
-

window.usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master4.85ms - 4.85ms-faster ✔
0% - 0%
0.00ms - 0.00ms
preact-local4.85ms - 4.85msslower ❌
0% - 0%
0.00ms - 0.00ms
-
text_update
  • Browser: chrome-headless 86.0.4240.183
  • Sample size: 240
  • Built by: CI #501
  • Commit: 74f22d0

duration

VersionAvg timevs preact-mastervs preact-local
preact-master3.29ms - 3.50ms-unsure 🔍
-6% - +4%
-0.19ms - +0.13ms
preact-local3.30ms - 3.55msunsure 🔍
-4% - +6%
-0.13ms - +0.19ms
-

window.usedJSHeapSize

VersionAvg timevs preact-mastervs preact-local
preact-master0.82ms - 0.82ms-faster ✔
0% - 0%
0.00ms - 0.00ms
preact-local0.82ms - 0.82msslower ❌
0% - 0%
0.00ms - 0.00ms
-

tachometer-reporter-action v2 for CI

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Nov 1, 2020

Size Change: -17 B (0%)

Total Size: 41.8 kB

Filename Size Change
dist/preact.js 4.02 kB -2 B (0%)
dist/preact.min.js 4.05 kB -3 B (0%)
dist/preact.module.js 4.04 kB -4 B (0%)
dist/preact.umd.js 4.08 kB -8 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.19 kB 0 B
compat/dist/compat.module.js 3.21 kB 0 B
compat/dist/compat.umd.js 3.25 kB 0 B
debug/dist/debug.js 3.12 kB 0 B
debug/dist/debug.module.js 3.11 kB 0 B
debug/dist/debug.umd.js 3.21 kB 0 B
devtools/dist/devtools.js 185 B 0 B
devtools/dist/devtools.module.js 195 B 0 B
devtools/dist/devtools.umd.js 261 B 0 B
hooks/dist/hooks.js 1.13 kB 0 B
hooks/dist/hooks.module.js 1.15 kB 0 B
hooks/dist/hooks.umd.js 1.2 kB 0 B
jsx-runtime/dist/jsxRuntime.js 298 B 0 B
jsx-runtime/dist/jsxRuntime.module.js 306 B 0 B
jsx-runtime/dist/jsxRuntime.umd.js 375 B 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

@coveralls
Copy link
Copy Markdown

coveralls commented Nov 2, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 621a369 on fix-next-dom into e38d066 on master.

Comment thread test/browser/lifecycles/shouldComponentUpdate.test.js Outdated
@JoviDeCroock JoviDeCroock marked this pull request as ready for review November 15, 2020 12:07
Comment thread src/diff/children.js
vnode._parent = childVNode;

if (typeof vnode.type == 'function') {
reorderChildren(vnode, oldDom, parentDom);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We'd need to find a way to tell whether or not we have to traverse further:

const Cell = () => (
  <Fragment>
    <div>x</div>
    <Fragment><div>y</div></Fragment>
  </Fragment>
)

When this Cell bails we need to ensure we move y as well as x when this is moved from the top. Before this change we would forget about y within diffChildren but move it from diff.shouldComponentUpdate = false.

Comment thread src/diff/children.js Outdated
@JoviDeCroock JoviDeCroock changed the title attempt at fixing how we reorder children when we bailout Move child reodering to diffChildren Nov 17, 2020
Comment thread src/diff/children.js
);
if (
typeof childVNode.type == 'function' &&
childVNode._children === oldVNode._children
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This signals that we bailed out either due to strict equality or SCU false

Copy link
Copy Markdown
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

This looks really great! In the longterm I think we have to go with moving the placing of children into diffChildren either way 👍

Does this change catch a new bugs where we'd need a test for or is it mostly byte savings?

@JoviDeCroock
Copy link
Copy Markdown
Member Author

@marvinhagemeister mainly savings and readability

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.

4 participants