Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Pool commentState allocations #1286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from
Open

Conversation

jakebailey
Copy link
Member

These comment states appear to be one of the main allocators when emitting the VS Code codebase. Pool them within a print run.

Reduces the VS Code alloc count from 36015276 to 28140625 (20% reduction).

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a commentStatePool to reuse commentState instances and significantly reduce allocations when printing. It replaces direct allocations of commentState with pooled instances in various emitComments methods.

  • Added a core.Pool[commentState] field to Printer
  • Updated emitCommentsBeforeNode to retrieve and initialize a pooled commentState
  • Switched emitCommentsBeforeToken and emitCommentsAfterToken to use pooled instances instead of fresh allocations

internal/printer/printer.go Show resolved Hide resolved
internal/printer/printer.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.