Conversation
|
|
Digging into this PR, it seems we are doing more |
|
Man, I'm totally flummoxed by this. Firstly, the tests pass locally, I have no idea why they don't in CI. Secondly, this is slower than diff --git a/packages/svelte/src/internal/client/dom/hydration.js b/packages/svelte/src/internal/client/dom/hydration.js
index d51ae78ca..1a7c1bedb 100644
--- a/packages/svelte/src/internal/client/dom/hydration.js
+++ b/packages/svelte/src/internal/client/dom/hydration.js
@@ -40,6 +40,7 @@ export function hydrate_anchor(node) {
/** @type {Comment} */ (node).nextSibling
);
+ var nodes = [];
var current = hydrate_start;
var depth = 0;
@@ -51,6 +52,7 @@ export function hydrate_anchor(node) {
depth += 1;
} else if (data[0] === HYDRATION_END) {
if (depth === 0) {
+ hydrate_start = nodes[0];
return current;
}
@@ -58,6 +60,7 @@ export function hydrate_anchor(node) {
}
}
+ nodes.push(current);
current = /** @type {import('#client').TemplateNode} */ (current.nextSibling);
}...it speeds up again. This offends reason. |
Dare I say it, do we just do this to get this PR landed? Obviously with comments explaining why. We can then at least compare this to the other PR of yours and see where we go with that. Also it seems your recent tweaks caused the tests to fail? |
|
Merged #12215 so will close this |
We create an array of nodes when hydration, and attach it to effects as the
domproperty. In non-hydration mode, we turn aDocumentFragmentinto an array of nodes.This all creates extra work and allocates extra memory. I was curious as to whether we could speed up hydration by just storing the 'bookends', taking advantage of the fact that the DOM is basically a bunch of linked lists. In this PR there's no more
hydrate_nodes, justhydrate_startandhydrate_end, andeffect.domhas been replaced byeffect.d1andeffect.d2.It seems to be faster in some cases but not all (perhaps because I'm prepending fragments with an empty text node so that
effect.d1isn't shared between multiple effects, which makes life rather complicated). More investigation needed. I do think the code is a little nicer this way, so I'm hopeful that it can be made faster in all cases.Before submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint