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

Extremely slow with 100% CPU usage #8801

Open
1 task done
HommeSauvage opened this issue Jul 22, 2024 · 4 comments
Open
1 task done

Extremely slow with 100% CPU usage #8801

HommeSauvage opened this issue Jul 22, 2024 · 4 comments
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage

Comments

@HommeSauvage
Copy link

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

Not easy to reproduce as it's a monorepo with lots of files to build

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Which canary version will you have in your reproduction?

2.0.9

Describe the Bug

When build a monorepo with 43 packages, turbo is being EXTREMELY slow and basically blocks the computer at 100% usage.

If I run the same build of the whole monorepo with pnpm -r build, there is some usage, but the expected kind of CPU usage, it build without issues and I can continue to work.

With turbo, same number of packages to build, it blocks completely the computer with 100% usage. I tried to build with the profiler on, here's the link: https://github.com/DriveFlux/turbo-debug/blob/main/profile.json

Expected Behavior

To build with roughly the same CPU usage as pnpm -r build

To Reproduce

To have a mixture of a couple of packages with prisma (each package generates its own prisma file) and we use SWC to build.

I would like to share the profile first, if that doesn't help, I will try to invest some time in making a complete reproduction.

Additional context

One funny thing happening with turbo versus pnpm is the appearance of the little window for a split second for each package being built (It's verifying something it seems, the same kind of window you get when running a new software). This doesn't happen with pnpm -r build.

Here's the turbo.json file:

{
	"$schema": "https://turbo.build/schema.json",
	"ui": "tui",
	"globalEnv": ["NPM_TOKEN", "USE_ENV"],
	"tasks": {
		"build": {
			"dependsOn": ["^build", "lingui:compile", "validate-config"],
			"outputs": [".next/**", "!.next/cache/**", "dist/**"]
		},
		"type-check": {
			"cache": false
		},
		"check": {
			"cache": false
		},
		"lint": {
			"cache": false
		},
		"lint:errors": {
			"cache": false
		},
		"format": {
			"cache": false
		},
		"i18n": {
			"inputs": ["**/*.tsx", "**/*.ts"],
			"outputs": ["locales/**/*.mjs"]
		},

		"@org/scheduler#build": {
			"dependsOn": ["^@org/email#build", "^build"],
			"outputs": ["dist/**"]
		},

		"@org/subscription#build": {
			"dependsOn": ["^@org/billing#build", "^build"],
			"outputs": ["dist/**"]
		},

		"dev": {
			"persistent": true,
			"cache": false
		},
		"definitions": {
			"dependsOn": ["schema"],
			"outputs": [".definitions.json"]
		},
		"schema": {},
		"//#watch:packages": {
			"dependsOn": ["//#is-not-watching"],
			"persistent": true,
			"cache": false
		},
		"//#is-not-watching": {
			"cache": false
		},
		"lingui:compile": {
			"inputs": ["locales/**.po"],
			"outputs": ["locales/**.mjs"]
		},
		"validate-config": {
			"cache": false
		}
	}
}
@HommeSauvage HommeSauvage added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage owned-by: turborepo labels Jul 22, 2024
@pawelblaszczyk5
Copy link

pawelblaszczyk5 commented Jul 23, 2024

Out of curiosity, does it happen with the old ui as well for you? Because I have similar issue that was fixed by disabling the new one.

@chris-olszewski
Copy link
Member

One funny thing happening with turbo versus pnpm is the appearance of the little window for a split second for each package being built

Can you elaborate on this? This seems highly suspect. Are you referring to a macOS popup window like this:
image

@HommeSauvage
Copy link
Author

HommeSauvage commented Jul 26, 2024

No, it's difficult to catch the little window, it's just verifying a bin. I had to do a screen recording to catch the window as it disappears immediately.

The bin is a node module from the monorepo. The funny thing is that macOS was not verifying it and just runs it when using pnpm or turbo v1. However, when we run it with Turbo UI, it does the verification. It could be due to the updates of swc maybe? Because we use that inside fab.js which itself is just a commander program that calls swc build.

But again, only turbo UI seems to trigger this. Also, the XProtectService process works a lot.

Subsequent builds (even when there's no cache) do not have this problem.

Screenshot 2024-07-26 at 1 20 58 PM

Added note. The fab.js is called directly with #!/usr/bin/env node at the top. I'll try to remove that and see if it continues.

@HommeSauvage
Copy link
Author

Removing shebang didn't change much. Removing the ui definitely makes the build faster and uses less resources. Notice the difference of usage (the spike in between is just the start of my build process and checks). See before (ui) and after (no ui) the spike.

With ui, XProtectService process uses a lot more CPU.

Screenshot 2024-07-26 at 1 36 29 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage
Projects
None yet
Development

No branches or pull requests

4 participants