-
Notifications
You must be signed in to change notification settings - Fork 11
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
Benchmark with react-redux-benchmarks #3
Comments
Re-run all benchmarks with React 16.8.2 and react-hooks-easy-redux v1.0.0.
|
Updated react-hooks-easy-redux v1.1.1.
|
Average FPS in summary: react-redux 5.0.7: 51.89 |
It might be interesting to try with new commits in react-redux: reduxjs/react-redux#1177 (comment) |
Also might want to merge down from the latest version of the benchmarks repo - I've updated it to capture initial mount times and subsequent average render times. |
Merged down from the upstream of the benchmarks repo.
|
react-hooks-easy-redux v1.1.1:
react-hooks-easy-redux 23e2c5a -> v1.2.0:
|
Rerun all benchmarks with react-hooks-easy-redux v1.2.0:
|
Benchmark Summary for various React/Redux libraries:
|
Wanna try tossing the experimental v7 alpha in there too? |
Well, it's not very surprising.
|
Merged upstream/master which includes reduxjs/react-redux-benchmarks#19. Rerun benchmarks with react-hooks-easy-redux v1.3.0:
|
I converted deeptree for react-hooks-easy-redux.
|
Oops, Pair.jsx is not used at all... |
@dai-shi : yeah, there's a bunch of junk left over in some of those benchmarks that I need to clean up :) |
Latest benchmark resultsreact-redux 5.1.1
react-redux 7.0.0.beta-0
react-hooks-easy-redux 1.4.0
|
@dai-shi : I'd encourage you to try to get the other benchmarks working too for comparison |
setupgit clone https://github.com/dai-shi/react-redux-benchmarks.git
cd react-redux-benchmarks
npm install
npm run initialize
REDUX=7.0.0.beta-0 BENCHMARK_TRACE=false BENCHMARKS=tree-view:tree-view-rher:deeptree:deeptree-rher:twitter-lite:twitter-lite-rher npm start resultstree-view (react-redux 7.0.0.beta-0)
tree-view (react-hooks-easy-redux 1.6.0)
deeptree (react-redux 7.0.0.beta-0)
deeptree (react-hooks-easy-redux 1.6.0)
twitter-lite (react-redux 7.0.0.beta-0)
twitter-lite (react-hooks-easy-redux 1.6.0) with React.memo (is it fair?)
|
Very compelling results. It almost feels like in real world usage with complex apps, using @theKashey's proxyequal will be faster than manual specification of Mount and Avg are millseconds (for initial component mount and average re-render), correct? |
Guess so. @markerikson ?
We really want to run benchmarks with real-world examples.
That's my expectation too. 😉 |
Wow. This is amazing! Magic out of the box!
That was a reason I've started all this. I had too many cases when manual memoization, selection and optimization would be too hard, even with years of experience. After a year fully into it(proxyqual was released exactly a year ago) I don't see any problem with it for myself, but I remember how I struggle, and I could see the same sadness in the eyes of mine friends. Anyway - I remember that a few my applications(displaying biiiig tables) got slower after adding I should double check it. |
Yes, the times in that "render" column are in milliseconds. FWIW, long-term I'm totally interested in the idea of "auto-magic" behavior in React-Redux itself. However, my own focus for now has to simply be on making sure that the current implementation works as needed (and as expected). So, please keep on experimenting with this stuff, and perhaps if it works out, we may be able to adopt some of your work. |
like :mindblow: slices :mindblow: |
I was just looking at it last weekend. I thought the use of Map is not necessary, and tried eliminating it. |
@epeli You might want to check some benchmark results here. I'm now converting another scenario. |
Newly converted benchmark: stocktickerhow to rungit clone https://github.com/dai-shi/react-redux-benchmarks.git
cd react-redux-benchmarks
npm install
npm run initialize
REDUX=7.0.0.beta-0 BENCHMARK_TRACE=false BENCHMARKS=stockticker:stockticker-rher npm start react-redux 7.0.0.beta-0
react-hooks-easy-redux 1.6.0
This is tough, maybe because of getDerivedStateFromProps(), which can't be implemented in hooks. I mimicked with useMemo. Is there any better implementation? |
No problem with this. It just renders only once. |
stockticker benchmarkshow to rungit clone https://github.com/dai-shi/react-redux-benchmarks.git
cd react-redux-benchmarks
git checkout e3f37855e2969591c51b3e14262969d6d426fa37
npm install
rm sources/*/yarn.lock
BENCHMARKS=stockticker:stockticker-useReduxState:stockticker-useReduxStateMapped:stockticker-rrh npm run initialize
REDUX=7.0.0-beta.0 BENCHMARK_TRACE=false BENCHMARKS=stockticker:stockticker-useReduxState:stockticker-useReduxStateMapped:stockticker-rrh npm start results
notes
|
It's good to have a slow example - easier to detect friction points (is there any?) |
FWIW, I'd suggest focusing on the |
Agreed. This one isn't something you'd do in a normal Redux app (i.e. it's quite contrived). However we gotta get to the bottom of what makes the proxy solution slow here. It's an important clue regarding the current weakness of this approach. |
Understood.
Agreed too.
I have no clue at the moment. |
If it's just a consequence of the work Proxies are doing, a non-redux benchmark of calling the I.e. it might be useful to get a real idea how many cycles the proxy approach is running through. |
There are a few obvious wars to speed up it a bit:
Proxyequal is very hot spot, and it’s probably worth to rewrite it. We might keep all the tests to keep it “right” (I’ll add a few failing ones), and make it more perfomant. |
1: string concatenation vs. object creation. not sure which is faster. |
1: string concatenation and de-concatenation vs. object creation. It's more about CPU vs GC. |
What is |
So what I am going to spike:
In short - gonna rewrite proxyequal from a scratch. |
FYI: just replacing with |
Not a surprise - it was faster than |
With regard to
It won't trigger render, but comparing every time obviously. baseline
with the hack
Still, there seems to be some other causes, to compare with For reference, here the code of Slice.jsx: import React from "react";
import { useReduxState, useReduxDispatch } from "reactive-react-redux";
import Pair from "./Pair";
import { fillPairs } from "./pairActions";
const Slice = ({ idx }) => {
const state = useReduxState();
const dispatch = useReduxDispatch();
const slice = state[idx];
return (
<ul className="list-group">
{slice.map(pair => {
return <Pair key={pair.id} sliceId={idx} pairId={pair.id} />;
})}
</ul>
);
};
Slice.displayName = "Slice";
export default Slice; |
|
Instead of react-redux-benchmarks, I tried benchmark with js-framework-benchmark. The result seems somewhat realistic, doesn't it? |
This wasn't the main reason of the slowness. The slowness is more by many comparisons with small affected like the following.
|
Death by a thousands cuts. Probably it worth so store used keys in a nested object form the beginning, then we would be able to:
|
Comparing v2 and v3useReduxState in v2.0.1git clone https://github.com/dai-shi/react-redux-benchmarks.git
cd react-redux-benchmarks
git checkout 43cc0b92fef86ee222014e3263704be34da29556
npm install
rm sources/*/yarn.lock
BENCHMARKS=deeptree-nested-useReduxState:deeptree-useReduxState:forms-useReduxState:stockticker-useReduxState:tree-view-useReduxState:twitter-lite-useReduxState npm run initialize
REDUX=7.0.2 BENCHMARK_TRACE=false BENCHMARKS=deeptree-nested-useReduxState:deeptree-useReduxState:forms-useReduxState:stockticker-useReduxState:tree-view-useReduxState:twitter-lite-useReduxState npm start
useReduxState in v3.0.0git clone https://github.com/dai-shi/react-redux-benchmarks.git
cd react-redux-benchmarks
git checkout 09d621170ca2536ba14001b40972bb39c8f72191
npm install
rm sources/*/yarn.lock
BENCHMARKS=deeptree-nested-useReduxState:deeptree-useReduxState:forms-useReduxState:stockticker-useReduxState:tree-view-useReduxState:twitter-lite-useReduxState npm run initialize
REDUX=7.0.2 BENCHMARK_TRACE=false BENCHMARKS=deeptree-nested-useReduxState:deeptree-useReduxState:forms-useReduxState:stockticker-useReduxState:tree-view-useReduxState:twitter-lite-useReduxState npm start
Summary
Numbers are Avg FPS. |
Benchmark with js-framework-benchmark forked repo |
Just for fun, I ran a single benchmark (deeptree-nested) with all versions to see the change over development time. Don't trust the numbers too much, like v2.0.0 and v2.0.1 shouldn't be that different. |
Thats amazing! Not only performance boost, but also the graphs. |
The latest benchmark result with js-framework-benchmark. |
I wouldn't care much, but "Startup metrics" show slowness for reactive-react-redux. I'm curious a bit. |
Just 10% slower. And you might spent months to make it 5% faster. I would propose just keep it as is, and revisit it after... vacations. Always helps with new ideas. |
I'd close this issue. Some of early discussions are no longer valid. Let's open a new issue for further discussions. The latest benchmark result as of writing is here. |
Continuing from: #1 (comment)
Note:
The text was updated successfully, but these errors were encountered: