Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Increase overall performance by speeding up GoDocumentSymbolProvider #1766

Merged
merged 16 commits into from
Jul 16, 2018

Conversation

JacksonKearl
Copy link

@JacksonKearl JacksonKearl commented Jul 3, 2018

This removes massive copy overhead from recreating Buffers of the entire document for every symbol in the file. Also reduces the quadratic time approach to converting from byte-offsets to character-offsets to log-linear time.

Hopefully closes #1668.

Jackson Kearl added 4 commits July 2, 2018 15:16
Decreases time to get symbols by 1-2 orders of magnitiude in large files
This in turn seems to speed up formatting time.
Still WIP, will look for other performance pitfalls.
@JacksonKearl JacksonKearl reopened this Jul 3, 2018
@JacksonKearl JacksonKearl self-assigned this Jul 3, 2018
@OneOfOne
Copy link
Contributor

I have been using this for over a week, didn't run into any issues.

@JacksonKearl
Copy link
Author

@OneOfOne were you experiencing perf issues before?

@JacksonKearl
Copy link
Author

JacksonKearl commented Jul 13, 2018

@FiloSottile can you try this vsix and see if the performance improves?

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

Run some checks to compare numbers between existing code, this code and the intermediate solution of creating the buffer only once and then passing to convertToCodeSymbols

src/avlTree.ts Outdated
case -1: return BalanceState.SLIGHTLY_UNBALANCED_RIGHT;
case 1: return BalanceState.SLIGHTLY_UNBALANCED_LEFT;
case 2: return BalanceState.UNBALANCED_LEFT;
default: return BalanceState.BALANCED;
Copy link
Contributor

Choose a reason for hiding this comment

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

This would return balance when height difference is more than 2 which wouldn't happen in our case as we re-balance after adding every node, but for correctness sake, unbalanced left/right should be returned

src/avlTree.ts Outdated
/**
* Gets the value of a node within the tree with a specific key.
* @param key The key being searched for.
* @param root The root of the tree to search in.
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comment for closest

src/avlTree.ts Outdated
}

/**
* Gets the value of a node within the tree with a specific key.
Copy link
Contributor

Choose a reason for hiding this comment

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

Update the overall comment as well as the one for @return to convey that the "node" is returned not the "value of the node".
Same foes for the _get function

src/goOutline.ts Outdated
decls: GoOutlineDeclaration[],
symbols: vscode.SymbolInformation[],
containerName: string,
byteOffsetToDocumentOffset: (offset: number) => number): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

rename the parameter from offset to byteoffset here and every other place we are talking about converting byte offset to offset

src/goOutline.ts Outdated
}
});
}

public provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): Thenable<vscode.SymbolInformation[]> {
let t0 = Date.now();
Copy link
Contributor

Choose a reason for hiding this comment

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

unused variable

@ramya-rao-a ramya-rao-a merged commit aaf61a3 into microsoft:master Jul 16, 2018
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.

formatOnSave extremely slow at piping
3 participants