Project

General

Profile

Bug #2681

Poor performance

Added by Luke Murphey over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
04/22/2020
Due date:
% Done:

100%


index.jsx (4.27 KB) Luke Murphey, 05/05/2020 02:32 AM

History

#1 Updated by Luke Murphey over 4 years ago

I suspect that this is caused by excessive re-rending of the Reader view.

I also may want to debounce some of the calls: https://stackoverflow.com/questions/23123138/perform-debounce-in-react-js

#2 Updated by Luke Murphey over 4 years ago

Pain points:
  • Searching the works list

#4 Updated by Luke Murphey over 4 years ago

Getting this error: https://github.com/babel/babel/issues/9849

Seems fixed by importing regeneratorRuntime

#5 Updated by Luke Murphey over 4 years ago

I denounced the fetch call. This isn't the issue since I am filtering on the client side.

const fetchWorks = () => fetch(ENDPOINT_WORKS_LISTS());
const fetchWorksDebounced = AwesomeDebouncePromise(fetchWorks, 1500);

  async loadInfo() {
    try {
      const response = await fetchWorksDebounced();
      const works = await response.json();
      this.setState({ works });
    } catch (e) {
      this.setState({
        error: e.toString(),
      });
    }
  }

I updated to filter onChange. This is better but a search for "josephus" is still slow.

#7 Updated by Luke Murphey over 4 years ago

Obs:
  • Searching took 3 ms according to console.time()
  • The UI seems to hang; like CPU is held up
  • This seems to be a problem for the first render, but is better after the first slow search
  • Seeing tons of LazyLoad componentWillUnmount()
  • I see lots of commitNestedUnmounts() which each take 50ms
Qs:
  • What is taking so long?
    • searching takes 3ms
    • rendering is not the problem either
  • [Yes] Is CPU usage high?
    • Two cores seem to hit 50% for a while
  • [No] Does removing LazyLoad help?
    • No
  • Why is the first load so much faster?
  • [Yes] Does reducing the number help much?
    • Very much so
  • [No] Does removing the handlers help?
    • No
  • [No] Is it better the the search matches few entries?
  • Use https://react.semantic-ui.com/behaviors/visibility/
  • Does rendering almost nothing help?
    • Very much so
    • Its the image that is causing the problem
Solns:
  • [No] Keep rendered components in a list; don't re-render
    • Performance seems no better
  • Do the search on the server-side
    • This would allow me to load related works easier too
  • Use another component

#8 Updated by Luke Murphey over 4 years ago

Attaching modified Reader/index.jsx

#9 Updated by Luke Murphey over 4 years ago

I could have these load on infinite scroll with https://react.semantic-ui.com/behaviors/visibility/

#10 Updated by Luke Murphey over 4 years ago

[Violation] 'setTimeout' handler took 50ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 52ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 53ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 51ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 51ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 50ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 51ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 51ms
react-dom.development.js:174 [Violation] 'setTimeout' handler took 17306ms
[Violation] 'setTimeout' handler took 17332ms
[Violation] Forced reflow while executing JavaScript took 16757ms

#11 Updated by Luke Murphey over 4 years ago

The

Qs:
  • Is there another callback that seems to work?
Solns:
  • Use another call back
    • onOnScreen: same
  • Show the first few regardless
Refs:

#12 Updated by Luke Murphey over 4 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF