-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionaly patch nodes by keys. #357
Conversation
Good job, keep going 🙂 I'll add keyed Seed benchmark once it's merged and released. |
Hell yea brother |
I finally managed to do it right. Now I’m going to make a proper example and unit test, |
Here is the test app to play with. |
I did it! Later I will explain how the algorithm works and why I consider it better than ELM's one. |
Very cool! Let me know when I should dive into the code. Also I've written list of potential optimizations - #385 - feel free to update/extend (not only) |
ELM's algorithmTakes two nodes the old and the new one. Suggested alorithmSuppose we have old and new child nodes with el_keys: old: [a] [b] [c] [d] [e] [f] [k] [l] The algorithm starts by taking nodes form the source iterators one by one in turn (new and old) old: [a] Now we have the matching key in queues. The algorithm takes nodes from the queues and yields But then nodes become diverse: old: [b] [c] As soon as the algorithm finds the matching key [b] it yields three commands: The algorithm continues to fill queues and stops with matching nodes [c]. Then it issues old: [c] Then nodes again become diverse: old: [d] [e] [f] The algorithm stops when finds the matching key [f] and yields three commands: At this point the source iterator for the new nodes has been exhausted and the algorithm old: [k] [l] At this point both source iterators are exhausted and the algorithm yields: As bonus we do not need to call the |
I'm not the author of the previous patching algorithm and I've only fixed some related bugs so I don't know how much it differs from the old code (except the keys). Please add also some tests so we don't break it during refactors. And perhaps we should copy-paste your previous comment to the code as the documentation. |
Yes. The text from previous comment already in the source code
documentation.
Tests will also be written.
…On Sat, 2020-03-21 at 13:32 -0700, Martin Kavík wrote:
I'm not the author of the previous patching algorithm and I've only
fixed some related bugs so I don't know how much it differs from the
old code (except the keys).
But your suggestions sounds good and Elm VDOM is fast so I don't see
any problems with it, nice.
Please add also some tests so we don't break it during refactors.
And perhaps we should copy-paste your previous comment to the code as
the documentation.
|
@MartinKavik @David-OConnor I'm ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first code review done. I've checked all files except patch.rs
and patch_gen.rs
. The most comments are about styling, best practices, missing docs etc., functionality looks good, thanks!
On Mon, 2020-04-13 at 04:52 -0700, Martin Kavík wrote:
@MartinKavik commented on this pull request.
Is it in a debug mode? What about release mode + configured wasm-opt
for size?
Yes it s in debug mode. I'll try to compile with optimization later.
Can we find out if those optimizations don't replace our inlines with
their original function calls (or optimize them away by another way)?
And what do you think about speed boost?
We could compile to WebAssebly text format and check the code.
As I know there no debuger for wasm.
I'm asking because on the first glance they look like a premature
optimization (or no optimization at all if the size is a trade-off
and speed boost isn't reasonable big). And it's another thing we have
to think about while writing and reading code, doing code reviews and
test (once the bechmarks are configured).
For the native binary performance boost could be significant. But
anyway we should do benchmarks to get the real numbers.
|
The keys are used by the diffing algorithm to determine the correspondence between old and new elements and helps to optimize the insertion, removal and reordering of elements. * New el_key attribute for Node. * New patch algorithm. * el_key example. Solves #354
We do not need to return the `web_sys::Node` from the functions applying the patch any more.
Note: Waiting for https://github.com/akhilman/seed/pull/1 |
Feat/keys upd
Thanks for fixes. |
I assume speed up is due to the fact that we no longer call the |
Patch old/new nodes by key if provided.
Continues #356
Solves #354
Progress: