How immutable data structures can _increase_ application performance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How immutable data structures can _increase_ application performance

Frank Shearar-3
http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/

In which David Nolen shows how |UIs built with persistent data
structures outperform those using mutable state, simply because you
can check for changes with a simple reference equality check. And you
get undo for free, and snapshots are trivial. And, because decent
persistent data structures share structure, it's memory efficient.

frank

Reply | Threaded
Open this post in threaded view
|

Re: How immutable data structures can _increase_ application performance

Levente Uzonyi-2
On Sun, 22 Dec 2013, Frank Shearar wrote:

> http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/
>
> In which David Nolen shows how |UIs built with persistent data
> structures outperform those using mutable state, simply because you
> can check for changes with a simple reference equality check. And you
> get undo for free, and snapshots are trivial. And, because decent
> persistent data structures share structure, it's memory efficient.

According to my benchmarks (and my memory) the immutable binary trees
(and other non-binary tree structures) I've built were all about 6x slower
than mutable ones. Spur might make a difference, because the extra cost
comes mostly from GC. But currently a mutable tree with a semaphore is way
faster.


Levente

>
> frank
>
>

Reply | Threaded
Open this post in threaded view
|

Re: How immutable data structures can _increase_ application performance

Frank Shearar-3
On 23 December 2013 00:43, Levente Uzonyi <[hidden email]> wrote:

> On Sun, 22 Dec 2013, Frank Shearar wrote:
>
>> http://swannodette.github.io/2013/12/17/the-future-of-javascript-mvcs/
>>
>> In which David Nolen shows how |UIs built with persistent data
>> structures outperform those using mutable state, simply because you
>> can check for changes with a simple reference equality check. And you
>> get undo for free, and snapshots are trivial. And, because decent
>> persistent data structures share structure, it's memory efficient.
>
>
> According to my benchmarks (and my memory) the immutable binary trees (and
> other non-binary tree structures) I've built were all about 6x slower than
> mutable ones. Spur might make a difference, because the extra cost comes
> mostly from GC. But currently a mutable tree with a semaphore is way faster.

In the article David calls out the fact that (a) persistent data
structures often are slower than mutable structure partly because (b)
they produce more garbage but that (c) _despite that_, the things that
use them can be way faster. Given a huge tree of objects (like the
DOM) you can check for changes by walking the tree with an extremely
fast reference check, instead of having to walk the properties of the
objects in the tree.

frank

> Levente
>
>>
>> frank
>>
>>
>