trunk-io / plugins

Trunk.io plugins repo
https://docs.trunk.io
MIT License
124 stars 39 forks source link

Trunk+VSCode keeps my coffee warm #287

Open Oni-giri opened 1 year ago

Oni-giri commented 1 year ago

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 :-)

det commented 1 year ago

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.

Oni-giri commented 1 year ago

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.

TylerJang27 commented 1 year ago

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!

Oni-giri commented 1 year ago
  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
laurit17 commented 1 year ago

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!

Oni-giri commented 1 year ago

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

Oni-giri commented 1 year ago

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.

laurit17 commented 1 year ago

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?

det commented 9 months ago

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.

TylerJang27 commented 8 months ago

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

philsherry commented 6 months ago

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
det commented 6 months ago

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?

Thank you for your feedback!

philsherry commented 6 months ago

👋🏻 @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.)