Skip to content
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

[menu-bar] Improve performance when running cli commands #61

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

gabrieldonadel
Copy link
Member

Why

Closes ENG-10052

How

To improve the performance of the runCommand method, this PR introduces the following optimizations:

  • Remove [task waitUntilExit], which blocks the main thread until the task is completed and use setReadabilityHandler and setTerminationHandlerinstead of relying on NSNotificationCenter for updates to allow asynchronous execution.

  • Move the NSTask execution and reading of output to a background queue

  • Use NSMutableString to avoid String concatenation on every update

Test Plan

Use Xcode Instruments to profile CPU usage

Before
image

After

image

@gabrieldonadel gabrieldonadel merged commit 929fd67 into main Sep 15, 2023
1 check passed
@gabrieldonadel gabrieldonadel deleted the @gabrieldonadel/fix-cpu-spikes branch September 18, 2023 17:18
gabrieldonadel added a commit that referenced this pull request Sep 18, 2023
* [menu-bar] Improve performance when running cli commands

* Add changelog entry
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