nosco / hx

A simple, easy to use library for React development in ClojureScript.
MIT License
249 stars 16 forks source link

Hiccup parsing perf improvements #49

Closed lilactown closed 5 years ago

lilactown commented 5 years ago

Before:

react x 1,468,464 ops/sec ±1.52% (57 runs sampled)
reagent x 325,920 ops/sec ±0.38% (62 runs sampled)
hx x 44,782 ops/sec ±0.65% (58 runs sampled)

Current After:

react x 1,720,359 ops/sec ±0.45% (62 runs sampled)
reagent x 337,924 ops/sec ±0.43% (61 runs sampled)
hx x 178,537 ops/sec ±0.51% (62 runs sampled)

hx is still lagging behind reagent by about 30%. Current goal is to flesh out benchmark with more cases, and be able to at least match reagent in most cases.

My dream would be to achieve ~50% of raw React, but that might require some tradeoffs that aren't worth it.

lilactown commented 5 years ago

Latest changes are pretty good:

react x 1,528,503 ops/sec ±2.25% (58 runs sampled)
reagent x 318,871 ops/sec ±0.52% (62 runs sampled)
hx x 319,236 ops/sec ±1.76% (60 runs sampled)

Some improvements were made to converting props obj back to map as well, though this benchmark doesn't reflect that.

Validating different cases to make sure I'm not introducing any regressions.

niwinz commented 5 years ago

Have you considered 100% static compilation of hiccup (something like this: https://github.com/rauhs/hicada) I'm using it in my own "rum" fork (still WIP the final api, because is used on a big project and I need to make changes incrementally...) and it has almost 0% overhead on top of react.

lilactown commented 5 years ago

@niwinz I have; I'm working on an experiment using reader tags https://github.com/Lokeh/thump

So far I enjoy it but it does have its tradeoffs. Will probably blog about it as I get closer to releasing to general use.