Scope validation performance boost#656
Merged
TwitchBronBron merged 17 commits intomasterfrom Sep 20, 2022
Merged
Conversation
Member
Author
TwitchBronBron
commented
Sep 19, 2022
|
|
||
| //do some file-based validations | ||
| if (isEnumStatement(node)) { | ||
| this.validateEnumDeclaration(node); |
Member
Author
There was a problem hiding this comment.
This was moved into the EnumStatement callback above.
TwitchBronBron
commented
Sep 19, 2022
|
|
||
| public processEvent(event: OnScopeValidateEvent) { | ||
| this.events.push(event); | ||
| event.scope.linkSymbolTable(); |
Member
Author
There was a problem hiding this comment.
Symbol table linking/unlinking happens at the program event level, we don't need to do it here anymore.
TwitchBronBron
commented
Sep 19, 2022
| private iterateFileExpressions(file: BrsFile) { | ||
| const { scope } = this.event; | ||
| //build an expression collection ONCE per file | ||
| const expressionInfos = this.expressionsByFile.getOrAdd(file, () => { |
Member
Author
There was a problem hiding this comment.
This is the core of the performance improvement. The expression info is computed once for each file (previously this would happen once per scope per file).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Several fixes:
While this hasn't restored the original performance lost in 0.53.0, it's a step in the right direction.

Breaking changes:
removed
NamespaceStatement.symbolTablein favor ofNamespaceStatement.getSymbolTable()because the symbol table for namespaces actually reside within theNamespaceStatement.bodyproperty. Since the symbolTable logic was only recently added, it's unlikely that many projects are referencing it.removed the
namespaceNamefrom several AstNodes, in favor of external consumers needing to call.findAncestor(isNamespaceStatement)instead. Note, this relies heavily on theAstNode.parentproperty which is set at the start ofonFileValidatefor each file. This is breaking because previously, the .namespaceName property was available immediately inafterFileParse. However, that logic was unsustainable for plugins that manipulate AST, and it's unlikely that many plugins are leveraging that property, so it is worth the breaking change.Here are the nodes with the removed property:
VariableExpressionDottedGetExpressionCallExpressionFunctionStatement