Comments (5)
@yoshuawuyts @leeoniya WOW these resources are INCREDIBLY helpful.
Thanks for diving into so much detail explaining the approaches, pitfalls and wishlist items with Choo's diffing. Being able to learn from other libraries that have been there done that is SO useful.
While, like you said, not all optimizations will be tackled right away (a lot of documentation, ergonomics and bug fixing will probably happen before "perfect-performance") knowing the direction to going in whenever someone begins tackling optimizing Percy's vdom is an AMAZING start!
I gave some of those links some quick scans, but I'll definitely be diving in to gain a better understand of our options here.
In terms of performance approach going forwards, what I have in mind is to have benchmark driven optimizations. So I think that it would be important to have a few benchmarks in place to start (and add more over time of course).
I'm thinking that our benchmarks could look like:
-
Diff benchmarks that diff two different trees. At first whatever worked.. Then over time organized in a way that made it INCREDIBLY easy to add new test cases. Sort of like our diff tests but instead inside of
#[bench]
tests. This could exist entirely in Rust since no real DOM nodes are needed -
Patch benchmarks that test how long it takes to apply diffs to real DOM elements. I'm thinking that for lightweight-ness these could be done in Node.js + jsdom similar to our integration tests.. but I'm not sure if we'd be missing out by not testing in real browsers. i.e. is getting faster in jsdom the same as getting faster in chrome/firefox/safari/etc?
I'm almost thinking that getting some basic benchmarks in place (that will probably end up being not-the-best as we learn more but at least it's a starting point to improve on) is step one in our vdom optimization story? Agree? Disagree?
Just ideas of course - thanks so much to both of you for all of this detail / insight!!
from percy.
fwiw, many of the libs that perform well here [1] use Longest Increasing Subsequence [2] when simple checks fail (common suffix and prefix, etc)
[1] https://github.com/krausest/js-framework-benchmark
[2] https://en.m.wikipedia.org/wiki/Longest_increasing_subsequence
from percy.
I'm almost thinking that getting some basic benchmarks in place (that will probably end up being not-the-best as we learn more but at least it's a starting point to improve on) is step one in our vdom optimization story? Agree? Disagree?
That sounds like a reasonable approach!
For our diffing algorithm we ended up writing about 100 tests by hand, and running another 200 or so each run using a random seed. I feel there's the possibility to do a much better job in Rust for that using proptest or quickcheck!
I don't think you need to test too many different browsers. Most of the DOM modification methods are consistent across browsers. nanomorph/lib/morph.js
contains some of the weirdest things we've found; so perhaps that will come in useful.
jsdom
will probably not yield the right results for actual testing. I remember we looked into it, but dropped it because certain methods were missing that we ended up using. Using the Electron-based tape-run ended up being much more reliable.
Hope this is useful!
from percy.
WOOHOO again your experience here is so appreciated!
Those tests are ππΏππΏππΏ thank you for linking. Yeah I think some of the crates out there can help give Percy a smooth testing story as things start coming together.
Hope this is useful!
Canβt even overstate it! Your comments have already probably saved dozens of people-hours! Ty ty ty ty!
from percy.
Added some thoughts on how we can get real browser benchmarking in place #22
from percy.
Related Issues (20)
- How alive is this project? HOT 3
- Use request_animation_frame from rust instead of Global Js call for update view HOT 3
- Free hosting? HOT 5
- Sub-routes not working? HOT 1
- Bash files in examples to rust-script? HOT 5
- Curly braces for value interpolation HOT 1
- Implement Performance Metrics HOT 2
- Implement a Formatting Tool HOT 2
- Consider Pure JS Transpilation HOT 2
- FYI: branding/naming clash HOT 1
- Crate renames HOT 1
- Docs: Broken CSS HOT 1
- Broken tests in html-macro 0.7.0 and 0.7.1 HOT 4
- Building nojs-first applications (and some thoughts about an isomorphic data layer) HOT 1
- Free Hosting for Demos HOT 1
- Allow Support for multiple parameters in `JSX` syntax HOT 4
- Spaces removed when isomorphic app is hydrated HOT 3
- File referred to in documentation doesn't exist
- Fix parenthesized blocks in html macro
- Panic happened in /allocator/free_list.rs that `new_page == 0` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from percy.