Skip to content
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

perf(refinementList): Stop creating URL for hidden refinements. #934

Merged
merged 1 commit into from
Mar 24, 2016

Conversation

pixelastic
Copy link
Contributor

This actually fixes all my perf issues on the SteamDB demo.

@algobot
Copy link
Contributor

algobot commented Mar 17, 2016

By analyzing the blame information on this pull request, we identified @vvo, @jerskouille and @bobylito to be potential reviewers

@vvo
Copy link
Contributor

vvo commented Mar 17, 2016

props are frozen so you cannot change them inside render, otherwise: legit change.

@@ -127,6 +128,8 @@ class RefinementList extends React.Component {
}

const limit = this.state.isShowMoreOpen ? this.props.limitMax : this.props.limitMin;
this.props.facetValues = this.props.facetValues.slice(0, limit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not doable in React, you need to get a new reference instead of modifying props

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by not doable? The above code is currently working.

Is that a React best practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok my bad, just saw the Travis tests. I'll fix it.

Can't we have an eslint rule to detect that somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it must exists yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise running npm test on your machine should have made them fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, tests went through without issues (I have an npm test on pre-push)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So its weird if they failed on travis, maybe you need to npm install

@vvo
Copy link
Contributor

vvo commented Mar 21, 2016

@pixelastic You need some modifications for this PR to be merged

@pixelastic
Copy link
Contributor Author

@vvo I've updated the PR to not update the this.props directly, but it still fails on Travis, while it's seems to be working locally.

@vvo
Copy link
Contributor

vvo commented Mar 22, 2016

Hmm the functional tests seems broken, I would say this PR breaks something because the functional tests are looking for [href=Appliances something] and they cannot find it anymore.

See the readme for how to launch the functional tests

https://github.com/algolia/instantsearch.js#functional-tests

This actually fixes all my perf issues on the SteamDB demo.
@pixelastic
Copy link
Contributor Author

I fixed the functional test. I actually had to make the change (passing a method to generate the url instead of the generated url) to each widget that was using the RefinementList component.

@vvo
Copy link
Contributor

vvo commented Mar 24, 2016

looks very nice and clean.

Should help a lot performance wise.

My mistake for generating the urls upfront in a desperate try to avoid render() calls by doing deep comparisons while since you activate the urlSync, every facet value is different at every user interaction (query is different, url is different, render)

ReactDOM.render(
<RefinementList
attributeNameKey="path"
collapsible={collapsible}
createURL={_createURL}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only "better" optimisation we could do is know upfront that urlSync is deactivated (thus, no different urls per facet values) but I do not see an easy way to do so.

And it may be an edge case we do not need to support.

@vvo
Copy link
Contributor

vvo commented Mar 24, 2016

LGTM, I had only one comment, let me know what you think @pixelastic

@vvo vvo merged commit 212f522 into develop Mar 24, 2016
@vvo vvo deleted the perf/url-refinement-list branch March 24, 2016 14:37
@vvo vvo removed the in progress label Mar 24, 2016
@pixelastic
Copy link
Contributor Author

I say we wait for it to become a bottleneck before fixing it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants