Giter VIP home page Giter VIP logo

Comments (5)

chinedufn avatar chinedufn commented on May 14, 2024 2

@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:

  1. 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

  2. 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.

leeoniya avatar leeoniya commented on May 14, 2024 1

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.

yoshuawuyts avatar yoshuawuyts commented on May 14, 2024

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.

chinedufn avatar chinedufn commented on May 14, 2024

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.

chinedufn avatar chinedufn commented on May 14, 2024

Added some thoughts on how we can get real browser benchmarking in place #22

from percy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.