question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[perf] on-demand vnode reuse

See original GitHub issue

domvm v2 is already fast [1], but i think it can get even faster if people are willing to write their templates a bit differently. this can be done in a backwards-compatible manner by adding an extra signature to the vnode factory functions.

Current signature:

var el = domvm.defineElement,
    vw = domvm.defineView;

function View(vm, data) {
  return () =>
    el("div", [
      el("em", "foo"),
      vw(ItemsView, data.items),
    ])
}

Body-generator signature:

var el = domvm.defineElement,
    vw = domvm.defineView;

function View(vm, data) {
  return () =>
    el("div", d => [
      d.el("em", "foo"),
      d.vw(ItemsView, data.items),
    ])
}

Here’s the idea:

Currently, the new vtree must be generated in full before being returned from render. This means all vnodes must be pre-allocated and after the oldVtree/newVtree diff pass, the old vtree is fully discarded by the GC - which takes time. By returning a body-generating function, we allow things to be lazy and pass in a “donator” d. What d’s methods do is a combination of findDonor and patch, where each vnode is located and re-used on demand from the oldVtree parent. As a result, we shorten the lifetime of any temporary vnodes and let the GC work more efficiently and allocate less stuff.

The syntax difference is small and clean when using ES6, so the templates stay concise (though the compiled ES5 versions would replace d => with function(d) {...} and be beefier).

this is speculation at this point, but i think it may work.

[1] https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-ts/table.html

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
leeoniyacommented, Mar 16, 2017

this turned out to be impractical and not worth it. the way in which internal passes are optimized makes implementing this quite ugly and using it quite ugly as well.

if anyone’s unhappy with domvm’s 10% overhead vs vanillajs, they can use another lib…or vanillajs.

0reactions
leeoniyacommented, Jun 1, 2017

this will be in v3

Read more comments on GitHub >

github_iconTop Results From Across the Web

LFS - IBM
Shows the zFS vnode cache statistics. It shows the number of currently allocated vnodes and the vnode hit ratio. Allocates and "Deletes" show...
Read more >
Network File System: NFS and Coda
Find *vnode* in server corresponding to client's vnode. ... No: client cache for better performance. ... Fill-on-demand clustering, swap in small programs ...
Read more >
solaris-internals-memory-diagrams.pdf
memory-mapped files--is performed with the vnode segment driver, seg_vn. ... Used for read-ahead or prefaulting of data as a performance opti-.
Read more >
Detailed explanation of virtual DOM and Diff algorithm
The performance of virtual DOM is positively related to the template size ... Clone reuse node vnode = ownerArray[index] = cloneVNode(vnode) ...
Read more >
Large-scale Virtualization in the Emulab Network Testbed
In addition, the same machine is used for Emulab vnodes as well as PlanetLab virtual servers. Reusing—indeed, sharing—such complex and crucial code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found