Skip to content

perf: preallocate instantiated symbol table - #64306

Merged
Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
camc314:codex/preallocate-instantiated-symbol-table
Sep 18, 2026
Merged

Jake Bailey (jakebailey) merged 1 commit into
microsoft:mainfrom
camc314:codex/preallocate-instantiated-symbol-table

Conversation

@camc314

Copy link
Copy Markdown
Contributor

Since we know the size that result is going to be, we can pre-allocate it with the correct length and avoid any intermediate re-allocations

Copilot AI balanced review requested due to automatic review settings September 17, 2026 06:58
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Sep 17, 2026
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 17, 2026
@typescript-automation

Copy link
Copy Markdown
Contributor

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment on lines +21055 to 21057
result := make(ast.SymbolTable, len(symbols))
for _, symbol := range symbols {
result[symbol.Name] = c.instantiateSymbol(symbol, m)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are they always unique? Or does this overallocate because dupes are common? I assume not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like they're always unique - every nonempty call had len(symbols) == len(result).

I ran this on the go test suite + vscode:

Workload Total calls Nonempty tables Calls with duplicates Most common nonempty hint → length
VS Code main project 211,390 14,668 0 2 → 2 (72.1%)
Go compiler suite 538,031 22,045 0 2 → 2 (73.8%)
@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Sep 18, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to the merge queue Sep 18, 2026
Merged via the queue into microsoft:main with commit c975de5 Sep 18, 2026
26 checks passed
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Sep 18, 2026
@jakebailey Jake Bailey (jakebailey) added the Domain: Performance Performance related label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Domain: Performance Performance related For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

3 participants