Repository navigation
Use React components for lines and line numbers - #2325
nathansobo wants to merge 5 commits into
Conversation
|
I'll patch this in and take a look ASAP (maybe tonight, but more likely Thursday). A flame chart from Chrome's CPU profiler will help us figure out where the time is spent. I am curious how much time is spent in Also adding in the dream team of @yungsters @jordwalke @sebmarkbage @zpao @spicyj @vjeux @syranide |
|
@petehunt Sorry, I've discovered an implementation error in my example. I should have been more careful. It's not clear that there's an issue with this new implementation now that this problem is fixed. I'll update soon. |
|
No problem. But for my info, how did you run this test case? I was able to build atom but not get the init to do anything. Also is there some sort of incremental build if I wanted to make changes to the core? Couldn't find it in the docs. |
|
Sorry for the delay on this. I want to regroup based on my discovery of that error and present you with better information than I did this time around. Please forgive the noise. |
|
@petehunt So fixing the bug definitely improved things, but using React components is still a bit slower, especially at faster scroll rates. It would be fantastic to have you review my implementation and make sure there's nothing else I could do to improve things. It would also be cool for you to run the benchmark yourself as you tried to do to get a sense of how we're putting pressure on React. Dev ModeIf I understand what you mean by "incremental build" correctly, you can run Atom in "dev mode", which will load all source code directly from a development directory so you won't need to build. Currently, you can run Atom in dev mode by placing the repository in Running the benchmarkI've added the benchmark code directly into the source, you can run it from master and this branch by opening the command palette via I've been running these tests on Thanks so much for taking a look at this. |
|
I forgot to add, you may want to comment out our |
|
Here's an updated comparison. I modified the benchmark to scroll at a constant rate of 500px every 10ms for 2s. The version with React components from this branch is about 14% slower at this speed. At 2000 px every 10ms, they both get worse, but the version with React components is still about 14% slower. |
|
Here's a bit more info. It's hard to know what to make of these flame charts because the events they record are about the same length even though as you see in the timelines, the manual updates are faster. I've tried to outline the basic stages of what's going on in an update. The main difference is that the manual graph has a long DOM update phase and an extremely short "receive component" phase. It's interesting that React is able to update the DOM so much faster, but has more overhead for the receive component portion. |
|
@nathansobo When I sum up your flamegraphs it appears that React is basically equally fast, but are some unmarked stuff at the edges I guess that might be it. @spicyj @vjeux Posted a gist yesterday which seemed to indicate that "dumb React-components" have significantly higher overhead over just plain inlining. So there's hopefully some performance to be squeezed out there. But it made me a bit curious, have you tried inlining |
|
@syranide Yeah the flame graphs are really confusing because they appear to take the same time, but that conflicts with the timeline info which shows React components being slower. That's a really interesting idea about inlining the line numbers. I will give that a try and post the results. |
|
@syranide I tried to inline everything with some caching for the generation of the Here is a timeline of all 3 versions scrolling 500px/10ms for 1s and 2000px/10ms for 1s. It didn't seem to make a substantial difference. |
|
@nathansobo Seeing as it at least seems to measurably improve performance (even though it technically shouldn't), if it doesn't complicate things unnecessarily for you. It seems to me that if you put the line numbers 5 and 5 (or so) in a component, that you should be able to get it down further, less overhead from React classes than the initial setup and less overhead from redundant descriptors from the inline setup (if that is an issue, which it should be). |
|
@syranide Yeah, you're right that it is a bit faster, but I'm not sure it's enough of an improvement to switch to it over the manual DOM manipulation approach. I'm tempted to use components for the simplicity of the code, but a fast user experience may trump clean code in this case. After playing with grouping lines a couple weeks ago, I'm not sure it's worth it. It seemed to increase layout time and was also pretty unwieldy to deal with when there were changes to the buffer. |
|
@nathansobo I guess the simplest implementation would be I'm working on #1570 and you might see a measurable improvement from it whenever it lands (and subsequent PRs), but I doubt it (at least short-term). |
|
This branch is pretty out of date, should we close this @nathansobo? |
|
Yeah I'm resigned to manual DOM manipulation for now. |









This PR switches back to React components for lines and line numbers. There is a ~14% performance penalty at larger scroll sizes, but the code is a lot easier to reason about. I would love input from @petehunt or another member of the React team regarding improving the performance.
As you can see below, the overhead appears to be significant over the current manual DOM manipulation approach. The first part of the timeline is an accelerating scroll in two different versions of the editor, the first full react from this PR, the second with manual DOM manipulation from master. Note the larger amount of yellow JS time in the first timeline.