plugins icon indicating copy to clipboard operation
plugins copied to clipboard

Trunk+VSCode keeps my coffee warm

Open Oni-giri opened this issue 1 year ago • 13 comments

Hello,

Thanks for the awesome "master-linter" - the UI/UX is great, it's very useful.

Just a little feedback, share by other dev friends : it's heavy on the processor, and we had to uninstall it (at least from VSCode) to solve the issue. After 5 minutes of code, compute usage would shoot to 100%, and my MacBook Air 2021 would get very, very warm.

I think the VSCode plugin is at fault, however the behavior persisted after I removed it, and stopped when I did a clean uninstallation. I reinstalled only the CLI tool after, which solved the problem.

Thanks for the good work, I hope this feedback helps :-)

Oni-giri avatar May 19 '23 11:05 Oni-giri

Thanks for the feedback @Oni-giri! We are actively working on reducing the resource usage of the vscode extension and will be sure to update this ticket when that work makes its way into a release.

det avatar May 31 '23 20:05 det

Thanks, I think there's a bug where trunk launches several instances of itself randomly. See the problem:

Capture d’écran 2023-06-16 à 17 22 53

I hadn't used it at all before, just had VS Code open (without the extension). I'll have to uninstall it yet again.

Oni-giri avatar Jun 16 '23 14:06 Oni-giri

Thanks for posting the screenshot. That sort of information is definitely helpful to us. Can you answer a few other questions:

  1. What trunk cli version are you running (trunk --version)?
  2. When you took that screenshot were you running trunk in multiple repos or just one?
  3. Do you have anything in the actions enabled section of your .trunk/trunk.yaml? Trunk can be configured to run using git-hooks, which will also start linting in the background. It's possible that's what happened here.

We're still actively working on trying to make resource usage less of a problem in general, and we will keep you updated when we have a fix you can try!

TylerJang27 avatar Jun 16 '23 18:06 TylerJang27

  1. Version 1.5.1
  2. Just one
  3. Here are the actions:
actions:
  disabled:
    - trunk-announce
    - trunk-check-pre-push
    - trunk-fmt-pre-commit
  enabled:
    - trunk-upgrade-available

Oni-giri avatar Jun 17 '23 01:06 Oni-giri

Hi @Oni-giri, we have made a lot of changes since 1.5.1 so we recommend you stay up to date if possible.

In 1.11.1, we made some optimizations to clean up stale jobs that should rein in the amount of resources that the Trunk extension is using. We also have a forthcoming release of the extension that will allow configuring the extension's CPU usage.

If you have any issues upgrading to 1.11.1, let us know!

laurit17 avatar Jun 27 '23 20:06 laurit17

Thanks @laurit17 for the answer! I just upgraded, I'll keep you updated.

Oni-giri avatar Jun 28 '23 01:06 Oni-giri

Hi @laurit17, new issue: Trunk is eating my memory alive!

Capture d’écran 2023-07-09 à 02 24 13
Analysis of sampling trunk (pid 7524) every 1 millisecond
Process:         trunk [7524]
Path:            /Users/USER/*/trunk
Load Address:    0x10041c000
Identifier:      trunk
Version:         ???
Code Type:       ARM64
Platform:        macOS
Parent Process:  ??? [1]

Date/Time:       2023-07-09 02:22:31.863 +0300
Launch Time:     2023-07-02 05:33:14.999 +0300
OS Version:      macOS 13.4.1 (22F82)
Report Version:  7
Analysis Tool:   /usr/bin/sample

Physical footprint:         2.8G
Physical footprint (peak):  2.8G
Idle exit:                  untracked

I can send you the full report by mail if you want.

Oni-giri avatar Jul 08 '23 23:07 Oni-giri

I would really appreciate any info you are able to provide, thanks. feel free to email any info you have to lauri [at] trunk [dot] io.

I'm also curious about your usage patterns. We'd expect fairly light memory usage from the trunk binary itself, with spikes from running linters.

Curious - do you also see this only when using the vscode extension. Do you run trunk from the command line as well? DO you get a high memory footprint if you are doing that too?

laurit17 avatar Jul 13 '23 18:07 laurit17

Please check out the latest version of trunk 1.81.1, we have fixed an issue that could occasionally cause trunk to consume CPU indefinitely.

det avatar Dec 26 '23 21:12 det

Hi @Oni-giri, have you had the chance to try this out on the latest versions (1.18.1 or 1.19.0)?

TylerJang27 avatar Feb 07 '24 21:02 TylerJang27

This is very much still an issue, btw. I have to kill groups of 4-6 trunk processes on a fairly regular basis.

Do any of the Trunk team actually use Trunk in a real-world project, with VS Code on a Mac?

cli:
  version: 1.21.0
plugins:
  sources:
    - id: trunk
      ref: v1.4.5

philsherry avatar Apr 02 '24 08:04 philsherry

Hi @philsherry,

Sorry you are experiencing this. For context, trunk will launch a daemon for every git repository you open. This daemon process will currently stay alive forever, but the next version of trunk will have the daemon auto shutdown after some period of inactivity. Could you please provide more information about what you are seeing?

  • Are you using multiple git repositories?
  • Are these trunk processes consuming a large amount of CPU? How much? Is it constant it sporadic?
  • Would auto shutdown of daemon processes solve the problem you are seeing?

Thank you for your feedback!

det avatar Apr 02 '24 18:04 det

👋🏻 @det

Have you tested this with many projects that use git submodules? Due to the nature of my work, I might have two instances of VS Code running, each with at least one submodule. Trunk CPU usage can be anywhere from ~40% to 90% during these times.

The thing is, I might never need to lint any of the files in those submodules—is it still spun up regardless, even if I have that directory in the ignore paths?

Could there be some kind of defer option available? “Don’t start trunking on this tree until the user issues a command in a file” kinda thing? (I’m literally thinking as I’m typing, so this might be a garbage idea, or even something that you already do.)

philsherry avatar Apr 05 '24 07:04 philsherry