Skip to content

Conversation

rchiodo
Copy link

@rchiodo rchiodo commented Oct 4, 2019

For #7483

Made a number of adjustments to increase perf

  • Change load all cells to not send updates on each cell added. Wait till they're all done
  • Change render of all cells to not use global state, this allows us to skip rendering cells that haven't changed
  • Rework intellisense to not react to sendInfo messages, but instead react to specific changes. SendInfo happens too often and is too expensive to parse constantly
  • Rework monaco editor to not update widget parents until absolutely necessary

Added some more unit tests for the intellisense changes.

There's still a bunch of work left to do though. We need to virtualize the monaco editors somehow as they are the big bottleneck on opening now. A notebook with 500 cells in it takes 10 seconds just to show the first render. Resizing after that requires 5 seconds after resizing the window to calm down.

@rchiodo rchiodo self-assigned this Oct 4, 2019
// Indicate not showing the editor anymore. The equivalent of this
// is not when we receive focus but when we GIVE focus to the markdown editor
// otherwise we wouldn't be able to display it.
this.setState({showingMarkdownEditor: false});
Copy link
Author

@rchiodo rchiodo Oct 4, 2019

Choose a reason for hiding this comment

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

This should be unnecessary as I changed the logic here. It uses the props to determine if showing the markdown editor or not. I'm going to remove this and make sure markdown editing still works #Resolved

} else {
cellVMs[i] = cloneDeep(cellVM);
cellVMs[i].useQuickEdit = false;
cellVMs[i] = immutable.merge(cellVM, { useQuickEdit: false });
Copy link
Author

@rchiodo rchiodo Oct 4, 2019

Choose a reason for hiding this comment

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

merge [](start = 51, length = 5)

crap, this is wrong. Merge is unnecessary here. #Resolved

@rchiodo
Copy link
Author

rchiodo commented Oct 4, 2019

                this.updateWidgetParent(this.state.editor);

Hmm, might be able to eliminate this. It would make resizing all of the controls faster. #Resolved


Refers to: src/datascience-ui/react-common/monacoEditor.tsx:389 in c590780. [](commit_id = c590780, deletion_comment = False)

@codecov-io
Copy link

codecov-io commented Oct 4, 2019

Codecov Report

Merging #7778 into master will increase coverage by 0.42%.
The diff coverage is 93.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7778      +/-   ##
==========================================
+ Coverage   58.75%   59.17%   +0.42%     
==========================================
  Files         496      498       +2     
  Lines       22158    22245      +87     
  Branches     3570     3573       +3     
==========================================
+ Hits        13019    13164     +145     
+ Misses       8321     8259      -62     
- Partials      818      822       +4
Impacted Files Coverage Δ
...ience/interactive-common/interactiveWindowTypes.ts 100% <100%> (ø) ⬆️
src/datascience-ui/interactive-common/mainState.ts 44.89% <66.66%> (ø)
...ve-common/intellisense/baseIntellisenseProvider.ts 37.35% <85.71%> (+10.41%) ⬆️
...active-common/intellisense/intellisenseDocument.ts 73.33% <95.91%> (+35.77%) ⬆️
...client/activation/languageServer/languageServer.ts 90.14% <0%> (-1.93%) ⬇️
src/client/activation/languageServer/constants.ts 100% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a155680...f3b44ba. Read the comment docs.

const cellVM = this.state.cellVMs.find(c => c.cell.id === cellId);
if (cellVM) {
const index = this.findCellIndex(cellId);
if (index >= 0) {
Copy link
Member

@IanMatthewHuff IanMatthewHuff Oct 7, 2019

Choose a reason for hiding this comment

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

Is it right here to be recomputing selection and focus if the deleted cell is either selected or focused? Will focused context ever not be in the selected cell? #WontFix

Copy link
Author

Choose a reason for hiding this comment

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

You mean the or statement? (this.pendingState.selectedCell === cellId || this.pendingState.focusedCell === cellId)?

The second half of this should always be true if the first half is, but it's just in case the logic gets messed up somewhere else.


In reply to: 332125334 [](ancestors = 332125334)

Copy link
Member

@IanMatthewHuff IanMatthewHuff Oct 7, 2019

Choose a reason for hiding this comment

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

Yeah, I wasn't sure if that was a tautology or not.

Like via this:
if (newSelect >= 0) {
newVMs[newSelect] = { ...newVMs[newSelect], selected: true, focused: focusedCell === newVMs[newSelect].cell.id };
}


In reply to: 332129126 [](ancestors = 332129126,332125334)

Copy link
Author

Choose a reason for hiding this comment

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

Oh we only want to change it if the selected item is the item being deleted, so it would be more like this:

if (newSelection === cellId)


In reply to: 332130707 [](ancestors = 332130707,332129126,332125334)

const content = this.isMarkdownCell() && !this.isShowingMarkdownEditor() ?
<div className='cell-result-container'>
<div className='cell-row-container'>
{this.renderCollapseBar(false)}
Copy link
Member

@IanMatthewHuff IanMatthewHuff Oct 7, 2019

Choose a reason for hiding this comment

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

This lets you delete a cell without selecting it? #WontFix

Copy link
Author

Choose a reason for hiding this comment

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

Yeah it should. You hover over it and click delete


In reply to: 332135165 [](ancestors = 332135165)

Copy link

@DonJayamanne DonJayamanne left a comment

Choose a reason for hiding this comment

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

Still a little confused with what's going on.
Thats primarily due to lack of domain knowledge.
Added a few comments, approving as they aren't show stoppers.

Adding a few comments in some places should address most of my concerns.

// Return our changes
changes = [
{
range: this.createSerializableRange(new Position(0, 0), new Position(0, 0)),

Choose a reason for hiding this comment

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

Wouldn't it be better to create a custom serializer/transformer. If tomorrow we forget to use this, then we wouldn't know exactly what wen't wrong. Or if another class has the same problem as Position.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry don't have the foggiest what you're referring to. You mean the function createSerializableRange?


In reply to: 332128183 [](ancestors = 332128183)

Choose a reason for hiding this comment

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

Yes. I'm assuming we are using createSerializableRange, because JSON.stringify faills or puts a lot of unwanted guff.

hideOutput={cellVM.hideOutput}
focusCell={this.focusCell}
selectCell={this.selectCell}
lastCell={lastLine !== null}
Copy link

@DonJayamanne DonJayamanne Oct 7, 2019

Choose a reason for hiding this comment

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

Wouldn't it be more efficient to track the selected cellId instead of the object!
Same applies to focusCell, selectedCell, lastCell #WontFix

Copy link

@DonJayamanne DonJayamanne Oct 7, 2019

Choose a reason for hiding this comment

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

Will improve overall perf in react too, as they are simple strings that are being passed around. #WontFix

Copy link
Author

Choose a reason for hiding this comment

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

Those values are the cell id. They're not the objects.


In reply to: 332130854 [](ancestors = 332130854)

Copy link
Member

@IanMatthewHuff IanMatthewHuff left a comment

Choose a reason for hiding this comment

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

:shipit:

@rchiodo rchiodo merged commit 218047c into master Oct 7, 2019
@rchiodo rchiodo deleted the rchiodo/perf_step_1 branch October 7, 2019 18:45
rchiodo added a commit that referenced this pull request Oct 10, 2019
* First idea - load cells all at once.
Change updates to not update full cell
Change global properties to be per cell
Change cells to check for updates before rendering

* Fix delete to not select at the same time

* Make a pending state and a rendered state to use for rendering
Some perf fixes for monaco editor. Skip laying out parent
etc until necessary

* Refactor intellisense to not take so much time on load

* More delete and move fixes for intellisense

* Fix markdown not switching
Fix markdown editor background

* Fix some of the time on first render

* Add some more unit tests and fix intellisense issue

* Add news entry and fix variable explorer open

* Remove unnecessary state change

* Remove unnecessary merge

* Comment change

* Postpone widget parent changes

* Add new dependency

* Update some comments and names to be clearer
@lock lock bot locked as resolved and limited conversation to collaborators Oct 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants