Coder Social home page Coder Social logo

starter cpu full load about turborepo HOT 13 CLOSED

vercel avatar vercel commented on August 21, 2024 21
starter cpu full load

from turborepo.

Comments (13)

marcinbunsch avatar marcinbunsch commented on August 21, 2024 6

I'm getting the same issue, I tracked it to this line: https://github.com/vercel/turborepo/blob/15a11406c196a1e3c4497601fa72b5e5a9b4154f/cli/internal/run/run.go#L344

When I comment it out, rebuild turborepo and run it on the sample, CPU usage drops to 0

I think I have an idea what's happening - RunState expects the tasks to run, then finish, but yarn dev in examples are actually long-running tasks that watch and rebuild code, so they never finish. Apologies if I'm wrong I don't really know go and just dabbled in the code for 2 hours.

As fas I can see, RunState is responsible for rendering this:

image

However, I had to set runOptions.stream to false to actually see this output, but the default is true and it's not actually possible to set it to false. I'm not really sure how to fix it, the only idea I had was to disable the listener when stream is false:

func (r *RunState) Listen(Ui cli.Ui, startAt time.Time) {
	if !r.runOptions.stream {
		return
	}

But this will essentially disable RunState and I doubt this is the desired fix. Anyway, hope this helps someone with the proper fix!

EDIT: I've actually realized that both cases rely on runOptions.stream being false, so I can actually move the check before and remove the two underlying checks. I've whipped up a PR that might serve as either a hotfix or a springboard for a better fix: #529

from turborepo.

nmcdaines avatar nmcdaines commented on August 21, 2024 3

I'm not a go developer and am trying to stumble my way through debugging this issue.
I was looking into how to get the cpuprofile and heap traces; however looking into the code:

I am going to continue to look into how I can get this code to run on SIGINT (any help would be appreciated). Hopefully that might help to find the source of the high cpu utilisation.

from turborepo.

thien-do avatar thien-do commented on August 21, 2024 2

So a workaround is to go to the app directly and run it from there?

from turborepo.

vavra7 avatar vavra7 commented on August 21, 2024 1

For me it is 10% of CPU usage when idle in case I'm running dev command with turbo. Comparing it to running all packages and apps dev commands separately with just yarn then my CPU load is approaching 0% when idle.

                   -`                    vavra@archlinux 
                  .o+`                   --------------- 
                 `ooo/                   OS: Arch Linux x86_64 
                `+oooo:                  Host: Zephyrus M GM501GS 1.0 
               `+oooooo:                 Kernel: 5.15.7-arch1-1 
               -+oooooo+:                Uptime: 5 hours, 3 mins 
             `/:-:++oooo+:               Packages: 1186 (pacman) 
            `/++++/+++++++:              Shell: bash 5.1.12 
           `/++++++++++++++:             Resolution: 1920x1080 
          `/+++ooooooooooooo/`           DE: GNOME 41.2 
         ./ooosssso++osssssso+`          WM: Mutter 
        .oossssso-````/ossssss+`         WM Theme: Adwaita 
       -osssssso.      :ssssssso.        Theme: Adwaita [GTK2/3] 
      :osssssss/        osssso+++.       Icons: Adwaita [GTK2/3] 
     /ossssssss/        +ssssooo/-       Terminal: gnome-terminal 
   `/ossssso+/:-        -:/+osssso+-     CPU: Intel i7-8750H (12) @ 4.100GHz 
  `+sso+:-`                 `.-/+oso:    GPU: NVIDIA GeForce GTX 1070 Mobile 
 `++:.                           `-/+/   Memory: 5745MiB / 32025MiB 
 .`                                 `/                   

from turborepo.

thien-do avatar thien-do commented on August 21, 2024 1

Also happen on Mac Air M1 :D Almost sold it for the 14 inch but then I found this issue

from turborepo.

JoeyEamigh avatar JoeyEamigh commented on August 21, 2024 1

+1 - 100% CPU usage on a single thread on Ubuntu 20.04 5950X CPU. When the apps are run separately it idles around 2% or less. Happy to help debug further.

from turborepo.

jaredpalmer avatar jaredpalmer commented on August 21, 2024

Can you run with --heap=heap and --cpuprofile=profile and DM me in https://turborepo.org/discord?

from turborepo.

wenerme avatar wenerme commented on August 21, 2024

@jaredpalmer No --heap or --cpuprofile flag, but have --profile,

./node_modules/.bin/turbo run dev --profile=prof

but prof was not written.

from turborepo.

jaredpalmer avatar jaredpalmer commented on August 21, 2024

Update: need to pass filenames to these flags. Sorry for confusion

Can you run with --heap=heap and --cpuprofile=profile and DM me in https://turborepo.org/discord?

from turborepo.

vavra7 avatar vavra7 commented on August 21, 2024

Can you run with --heap=heap and --cpuprofile=profile and DM me in https://turborepo.org/discord?

I run it with parameters as you instructed and files appeared in root. Not sure what extension of the files should be but they are empty anyway since both have 0 bytes.

from turborepo.

jonbellah avatar jonbellah commented on August 21, 2024

Seeing the same cpu load issue (using npm). Also getting an empty file when running with the --heap=heap and --cpuprofile=profile flags.

Screen Shot 2021-12-16 at 4 32 39 PM

MacBook Pro (16-inch, 2019)
2.4 GHz 8-Core Intel Core i9
64GB 2667 MHz DDR4

from turborepo.

legraphista avatar legraphista commented on August 21, 2024

Can replicate on windows too, one core is pegged at 100%.

After creating the repo via npx create-turbo@latest and running

yarn dev --scope=*docs* --heap=heap --cpuprofile=profile

I can confirm that it generates 0 sized files for heap and profile but I believe that's to be expected as I'm running it under watch mode, and it will never have time to write heap & profile to disk when closing the program.

Maybe this will help:

  • closing the program exits with code 1
  • it sometimes leaves orphan processes hanging around, occupying either port 3000 or 3001

from turborepo.

matthewp avatar matthewp commented on August 21, 2024

If you need an open-source example, this happens in the Astro repo: https://github.com/withastro/astro

If you run:

yarn
yarn dev

And wait, you'll see Turbo at 100% CPU.

from turborepo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.