Closed barneycarroll closed 3 months ago
Current strategy is to directly cache the final state virtual DOM of static templates for direct reuse, and cache the intermediary DOM (before iterating with cloning procedures and interpolation logic) for interpolated templates.
This is plenty good enough in principle but is currently failing to persist updates.
This is plenty good enough in principle but is currently failing to persist updates.
Fixed.
Version 1.0.1 exposes library internal functions as methods on the default export so caching strategy can be tested for. The nest step is to run performance tests compared to normal Mithril using https://github.com/pygy/bunchmark.js.
Since the initial speculations have been accomplished and there are no bugs with extant strategy, new issues can discuss further asks and tasks.
Template computations ought to be cached: any given literal invocation with the same non-interpolated strings can be uniquely identified pre-computation, and as such some of that computation (interpolation parsing etc) ought to be short-circuited on subsequent computations.
Caching strategies are therefore desirable to avoid redundant computation and optimise performance.
From first principles, it would be desirable to simply cache the virtual DOM structures produced by templates. However, this conflicts with Mithrils virtual DOM diff strategy, which short-circuits the diff algorithm in the event of an incoming virtual node having reference equality to the previous node in place.
This presents a roadblock to straightforward caching of the current transform strategy: we need to produce new virtual nodes during each pass of the render loop in order for interpolated values to be persisted.
Split transformation process
Currently:
Complexity is back-loaded, which minimises indirection and interstitial complexity but makes cache optimisation difficult.
Optimisation strategies:
Qualify placeholder substitutions after and before lexing
Qualifying the types of individual interpolation semantics before we produce Mithril vdom would allow us to strategise for different types of interpolation and optimise the process for caching: