dfilatov / vidom

Library to build UI based on virtual DOM
MIT License
415 stars 16 forks source link

Compatibility with React #257

Closed vitkarpov closed 7 years ago

vitkarpov commented 7 years ago

I've been thinking about the topic, because there're a lot of big projects written on top of React and, as I get it right, Vidom is much faster than React.

So it might be a very interesting to make an experiment on live project: use Vidom instead of React for a part of users to get some performance metrics. If Vidom is really faster and has no big disadvantages (which could be illuminated, btw), than a lot of projects can become more faster!

I'm sure you have thought about it too. What cons do you see here? Are there some particular qualities in Vidom which could make this experiment impossible?

dfilatov commented 7 years ago

@trueadm To have benchmark fair, I've got rid of cheet with usage functional components inside inferno implementation (https://github.com/dfilatov/vidom/commit/cb8129c047e07713c80d699f2279f652503ac3bd), enabled attributes escaping in https://raw.githubusercontent.com/trueadm/inferno/dev/packages/inferno/dist/inferno-server.js and now result is not so impressive:

                         mean time ops/sec
  vidom v0.5.4           1.712ms   584
  inferno v1.0.0-beta13  1.911ms   523
  react v15.4.0          18.618ms  54
trueadm commented 7 years ago

@dfilatov thanks for finding that, I've added that back in. I'm not sure how you enabled attribute escaping in my last version – it didn't have it in it.

Please can you try again with the latest from dev?

dfilatov commented 7 years ago

@trueadm

I'm not sure how you enabled attribute escaping in my last version – it didn't have it in it.

I've just added escapeAttr call around prop value stringifying.

Please can you try again with the latest from dev?

How to get compiled version of dev?

trueadm commented 7 years ago

@dfilatov Thanks mate. https://github.com/trueadm/inferno/blob/dev/packages/inferno/dist/inferno-server.js

You're escaping performance can be massively improved. You'll notice that the version I'm using only does a single o(n) lookup – whilst multiple replace calls and indexOf calls cost o(n) each.

thysultan commented 7 years ago

the results i get with statefull Components

                         mean time ops/sec 
  dio.js v3.1.0          1.438ms   696     
  vidom v0.5.4           1.759ms   569     
  inferno v1.0.0-beta13  1.958ms   511     
  react v15.4.0          18.150ms  55 
dfilatov commented 7 years ago

My current result (inferno v1.0.0-beta13 points to dev):

                         mean time ops/sec
  dio.js v3.1.0          1.309ms   764
  vidom v0.5.5           1.625ms   615
  inferno v1.0.0-beta13  1.861ms   537
  react v15.4.0          18.437ms  54
dfilatov commented 7 years ago

Guys, I think performance of all implementations is enough and we should cease fire here. We're completely out of the scope of this issue :)

leeoniya commented 7 years ago

alright, GC is now happy. this is what i'm getting:

dio.js v3.1.0          1.292ms   774
domvm v2               1.419ms   705
vidom v0.5.4           1.525ms   656
inferno v1.0.0-beta13  2.993ms   334
react v15.4.0          48.38ms   21

it's been fun guys, thanks! we're all in the same ballpark.

[1] https://gist.github.com/leeoniya/cfe75cf9c5eac5359cf8b7ea86b14f84

dfilatov commented 7 years ago

@leeoniya Again functional components? :)

leeoniya commented 7 years ago

no these are full/stateful sub-views. "functional components" in domvm would be just vnode generators, not constructors/view closures that return render() functions. have some faith!

the vnode generators version was about 15% faster than above.

trueadm commented 7 years ago

Inferno looks way off in that last bench. What one are you using?

leeoniya commented 7 years ago

just did a dumb pull and npm update. i'll believe whatever numbers you put up for Inferno. I just wanted to sanity check domvm against the others to make sure i'm not super wrong. Whenever I run these tests i get +/- 30 ops anyways, so the small diffs dont matter to me.

@dfilatov the vnode generator version looks like [1], though now that i bench it it's actually a bit slower, oh well :/

i'm off to bed, ping me if there's some glaring oversight. night!

[1] https://gist.github.com/leeoniya/d2f4a3da42318a0232d09cdba7f2cde4

leeoniya commented 7 years ago

my summary of this issue:

escalated

trueadm commented 7 years ago

On the side note, I made everyone aware of how shit regex is at performance – so some good did come out of it and you now all have fast escaping :D you all made me realise that inferno-server needed a good refactor.

On a side note, I still see you guys didn't actually use the update inferno-component and inferno from dev; you'll need to clear your NPM cache to do this. Sigh :(

You should be seeing these figures:

inferno v1.0.0-beta13  0.999ms   1001
dio.js v3.1.0          1.284ms   779
vidom v0.5.5           1.370ms   730
react v15.4.0          52.803ms  19

I'll publish to NPM later today to help you.

dfilatov commented 7 years ago

@trueadm I used dev version of inferno

thysultan commented 7 years ago

same ^^ not from npm, taken directly from from the dev repo.

trueadm commented 7 years ago

How did you both take it? Did you paste it directly into node_modules/inferno/packages/inferno-component.js. Did you also clean your NPM cache?

dfilatov commented 7 years ago

I pasted its content to node_modules/inferno-server/inferno-server.js

trueadm commented 7 years ago

Ah, I think I know what it is. I'm using Node 6.5, if I go to 7.1, Inferno performance drops by about 30% because of deopts in inferno-component. Meh :/

Also, vidom also deopts all over the place too using 7.1.

trueadm commented 7 years ago

Node 7.1:

  dio.js v3.1.0          0.978ms   1023
  inferno v1.0.0-beta13  1.069ms   935
  vidom v0.5.5           1.855ms   539
  react v15.4.0          42.710ms  23

Node 6.9:

  inferno v1.0.0-beta13  0.847ms   1181
  vidom v0.5.5           1.408ms   710
  dio.js v3.1.0          2.550ms   392
  react v15.4.0          48.104ms  21

I can get some people on the V8 team to have a look if we think there's an regression with Node 7.0.

trueadm commented 7 years ago

@dfilatov @thysultan @leeoniya I'll stop derailing this issue. :)

If you'd like to chat more about this, it would be awesome to talk somewhere better. Maybe the Inferno Slack? https://inferno-slack.herokuapp.com/ I can make a channel to talk SSR perf etc – we can help each other get even better perf and play with different optimisation techniques.

IMO the more we can help one another, the better we can improve the experiences and the JS community as a whole.

dfilatov commented 7 years ago

I've already registered in Inferno slack.

vitkarpov commented 7 years ago

I haven't yet, on my way :) Thanks!

вторник, 22 ноября 2016 г. пользователь Filatov Dmitry написал:

I've already registered in Inferno slack.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dfilatov/vidom/issues/257#issuecomment-262209714, or mute the thread https://github.com/notifications/unsubscribe-auth/AC3Nvxx9RkhbuR6Uo72hU31Q47_huU1rks5rAsnlgaJpZM4K3W-r .

Виктор.