Skip to content

The Code Helper process constantly uses 100%-200% CPU #1056

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

Closed
mockaroo opened this issue Sep 23, 2024 · 15 comments · Fixed by #1270
Closed

The Code Helper process constantly uses 100%-200% CPU #1056

mockaroo opened this issue Sep 23, 2024 · 15 comments · Fixed by #1270
Labels
question Further information is requested

Comments

@mockaroo
Copy link

What version of VS Code are you using?

Version: 1.93.1 (Universal)
Commit: 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
Date: 2024-09-11T17:20:05.685Z
Electron: 30.4.0
ElectronBuildId: 10073054
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Darwin arm64 23.6.0

What version of Tailwind CSS IntelliSense are you using?

v0.12.10

What version of Tailwind CSS are you using?

3.3.3

What package manager are you using?

yarn

What operating system are you using?

macOS

Tailwind config

const defaultTheme = require('tailwindcss/defaultTheme')

module.exports = {
  darkMode: 'class',
  theme: {
    extend: {
      fontFamily: {
        sans: ['Inter', ...defaultTheme.fontFamily.sans],
      },
      keyframes: {
        fadeIn: {
          '0%': { opacity: '0' },
          '100%': { opacity: '1' },
        },
        pulsate: {
          '0%, 100%': {
            'box-shadow': '0 0 4px rgba(0, 123, 255, 0), 0 0 6px rgba(0, 123, 255, 0), 0 0 8px rgba(0, 123, 255, 0.3), 0 0 10px rgba(0, 123, 255, 0)',
          },
          '50%': {
            'box-shadow':
              '0 0 6px rgba(0, 123, 255, 1), 0 0 10px rgba(0, 123, 255, 0.7), 0 0 12px rgba(0, 123, 255, 0.5), 0 0 14px rgba(0, 123, 255, 0.3)',
          },
        },
      },
      animation: {
        fadeIn: 'fadeIn 0.5s ease-in-out',
        pulsate: 'pulsate 1s infinite linear',
      },
    },
  },
  content: ['./app/views/**/*.html.erb', './app/helpers/**/*.rb', './app/assets/stylesheets/**/*.css', './app/javascript/**/*.{js,jsx}'],
}

VS Code settings

{
  "security.workspace.trust.untrustedFiles": "open",
  "editor.fontSize": 13,
  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "files.autoSave": "onFocusChange",
  "explorer.confirmDelete": false,
  "[xml]": {
    "editor.defaultFormatter": "DotJoshJohnson.xml"
  },
  "terminal.explorerKind": "external",
  "svelte.enable-ts-plugin": true,
  "github.copilot.advanced": {},
  "editor.minimap.enabled": false,
  "javascript.updateImportsOnFileMove.enabled": "always",
  "[svelte]": {
    "editor.defaultFormatter": "svelte.svelte-vscode"
  },
  "[erb]": {
    "editor.defaultFormatter": "elia.erb-formatter"
  },
  "github.copilot.enable": {
    "*": true,
    "plaintext": false,
    "markdown": true,
    "scminput": false
  },
  "explorer.confirmDragAndDrop": false,
  "explorer.fileNesting.patterns": {
    "*.ts": "${capture}.js",
    "*.js": "${capture}.js.map, ${capture}.min.js, ${capture}.d.ts",
    "*.jsx": "${capture}.js",
    "*.tsx": "${capture}.ts",
    "tsconfig.json": "tsconfig.*.json",
    "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb",
    "*.sqlite": "${capture}.${extname}-*",
    "*.db": "${capture}.${extname}-*",
    "*.sqlite3": "${capture}.${extname}-*",
    "*.db3": "${capture}.${extname}-*",
    "*.sdb": "${capture}.${extname}-*",
    "*.s3db": "${capture}.${extname}-*"
  },
  "editor.accessibilitySupport": "off",
  "git.enableSmartCommit": true,
  "git.confirmSync": false,
  "[rust]": {
    "editor.defaultFormatter": "rust-lang.rust-analyzer"
  },
  "tailwindcss-intellisense.trace.server": "verbose",
  "tailwindCSS.validate": false
}

Describe your issue

The Code Helper process associated with this extension constantly uses 100%-200% CPU:

$ ps aux | grep vscode-tailwindcss
user      77738 191.5  6.4 1596731728 1076320   ??  R    10:50AM   5:48.36 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/markbrocato/.vscode/extensions/bradlc.vscode-tailwindcss-0.12.10/dist/tailwindServer.js --node-ipc --clientProcessId=76805
user      77852   0.0  0.0 410732240   1408 s004  S+   10:53AM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn --exclude-dir=.idea --exclude-dir=.tox vscode-tailwindcss
@henrybenso
Copy link

having a similar issue with very high cpu usage

@baelter
Copy link

baelter commented Sep 26, 2024

Same, on ubuntu

@baelter
Copy link

baelter commented Sep 26, 2024

Output is

 Locating server…
Booting server...
Checking if /home/xxxx/main.css may be Tailwind-related…
Setting up server…
Listening for messages…
Searching for Tailwind CSS projects in the workspace's folders.

@temrb
Copy link

temrb commented Sep 28, 2024

in honesty, this has been an issue for almost 2 years. I remember reporting a similar issue (exactly the same: #593) they closed it and haven't worked on it since. They refer to #444 and close that as well-- made 3 years ago.

I am having similar issue with a higher end pc-- disabling / removing the plugin brought down cpu usage from 50% to 3% lol.

best option here is to remove the plugin as it drastically decreases performance of other VSCode features.

They understand this has been an ongoing issue for years though simply will not work on it.

@thecrypticace
Copy link
Contributor

This is incredibly bizarre. I'm not sure why our LSP would be using that much CPU. Feels like its stuck in an infinite loop or something.

Is there a possibility you (or anyone) can provide the project that is causing this to happen? I don't see this at all ever on our own projects and the nature of an LSP means it is incredibly difficult to debug things like this because they're so environment and project dependent.

@baelter
Copy link

baelter commented Oct 1, 2024

I think it happens when I'm not in a tailwind projects, so maybe it's stuck looking for a config file or something, that it will never find. Just guessing :)

@rustyx
Copy link

rustyx commented Mar 16, 2025

Same here on Ubuntu 24.04, running inside Docker, continuous 120% CPU use.

I have many projects in my workspace, most of which are not tailwind-based.

Attaching strace to the node process shows lots of activity similar to:

futex(0x5613c4c, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c4c, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
epoll_pwait(14, [{events=EPOLLIN, data={u32=17, u64=17}}], 1024, 0, NULL, 8) = 1
read(17, "\1\0\0\0\0\0\0\0", 1024)      = 8
futex(0x5613c4c, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c4c, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c4c, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613be0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x5613c48, FUTEX_WAKE_PRIVATE, 1) = 1
. . .

Needless to say, this makes the extension unusable.
Uninstalling the extension for now, until the issue is resolved.

@thecrypticace
Copy link
Contributor

@rustyx does this happen on the latest version of the extension? Also are you using the language server directly or doing so through VSCode?

@thecrypticace
Copy link
Contributor

@rustyx also is it possible you could provide a docker container setup that reproduces this issue?

@thecrypticace
Copy link
Contributor

thecrypticace commented Mar 17, 2025

I took a strace distribution (strace -c -p <pid>) running the language server on my projects folder which has lots of stuff in it — note that it does cross a mounted volume in Docker:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 82.57   21.753914         230     94356           epoll_pwait
  7.95    2.093985          19    107583           read
  6.17    1.626630          29     55016     29700 openat
  1.54    0.406314           5     67813     42524 statx
  1.27    0.334697          11     29907      1448 futex
  0.16    0.041425           1     25333           close
  0.11    0.029320          14      2025           munmap
  0.10    0.025229           3      6793           write
  0.05    0.014471           0     25540     25330 readlinkat
  0.03    0.007155           6      1134           madvise
  0.02    0.004354           3      1181           mprotect
  0.01    0.002953           0      5342           pread64
  0.01    0.002772           2       990           mmap
  0.00    0.000929         116         8           clone
  0.00    0.000786           2       285           getpid
  0.00    0.000476         476         1           wait4
  0.00    0.000268           3        68        49 ioctl
  0.00    0.000249           0       940           newfstatat
  0.00    0.000215           0       937           fcntl
  0.00    0.000138           2        49           fstat
  0.00    0.000079           3        20           rt_sigprocmask
  0.00    0.000076           0        87           brk
  0.00    0.000058          14         4         4 faccessat
  0.00    0.000035           4         8           sendto
  0.00    0.000029           0        30           recvmsg
  0.00    0.000024           8         3           pipe2
  0.00    0.000012           1         9           kill
  0.00    0.000010           1         9         3 epoll_ctl
  0.00    0.000009           3         3           socketpair
  0.00    0.000009           0        42           prlimit64
  0.00    0.000008           2         4           socket
  0.00    0.000004           0        13           getcwd
  0.00    0.000004           4         1           epoll_create1
  0.00    0.000004           0         8           uname
  0.00    0.000003           0         4           bind
  0.00    0.000002           1         2           rt_sigaction
  0.00    0.000002           0         8           getsockname
  0.00    0.000001           1         1           eventfd2
  0.00    0.000001           1         1           rt_sigreturn
  0.00    0.000001           0         8           getrusage
  0.00    0.000001           0         4           getpeername
  0.00    0.000001           0         8           getsockopt
  0.00    0.000001           1         1           shutdown
  0.00    0.000001           1         1         1 io_uring_setup
  0.00    0.000000           0         1           lseek
------ ----------- ----------- --------- --------- ----------------
100.00   26.346655          61    425581     99059 total

There's a decent chunk of futex(…) calls but they mostly disappear once everything is read. This also happened in about 15–20s on my machine (but that folder is also 60GB, has lots of node_modules, lots of tailwind projects, a bunch of git repo, some non-tailwind projects, etc…)

The most prevalent call after everything settles is epoll_pwait(…) which I believe is related to @parcel/watcher:

epoll_pwait(14, [], 1024, 2189, NULL, 8) = 0
getpid()                                = 373
kill(362, 0)                            = 0
epoll_pwait(14, [], 1024, 0, NULL, 8)   = 0
epoll_pwait(14, [], 1024, 2999, NULL, 8) = 0
getpid()                                = 373
kill(362, 0)                            = 0
epoll_pwait(14, [], 1024, 0, NULL, 8)   = 0
epoll_pwait(14, [], 1024, 3000, NULL, 8) = 0
getpid()                                = 373
kill(362, 0)                            = 0
epoll_pwait(14, [], 1024, 0, NULL, 8)   = 0
…

So, so far I'm not able to reproduce this. I'm gonna try running docker in a linux vm since fs access for a mounted volume may work a bit differently.

@thecrypticace thecrypticace added the question Further information is requested label Mar 17, 2025
@thecrypticace
Copy link
Contributor

So, so far I'm not able to reproduce this. I'm gonna try running docker in a linux vm since fs access for a mounted volume may work a bit differently.

syscalls look pretty similar so yeah need more information on how to reproduce this

@rustyx
Copy link

rustyx commented Mar 17, 2025

@thecrypticace there may be an issue with handling symlinks to parent directories. The project I work with has lots of those.

I could reproduce the issue locally on Ubuntu without the use of Docker. Try opening this workspace and then navigating to a/b/c/fmt.less.

@thecrypticace
Copy link
Contributor

Oh yeah there's absolutely an issue with recursive symlinks related to fast-glob — I opened an issue for reference purposes here: #1185

I think at this point I'm going to have to replace fast-glob. All I'd need is an extension point of "should I traverse into this folder" but it doesn't have one. Nor does tinyglobby. I might see if I can open a PR for that though b/c I'd rather not have to inline that library and then lose any future bug fixes

@thecrypticace
Copy link
Contributor

I think that multi-root workspace example is one of the first I've seen cause node to run out of memory though so that one is fairly useful — thanks!

@thecrypticace
Copy link
Contributor

I'm aiming to get a release out with this fixed today or tomorrow 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants