getappmap / getappmap/appmap-js

Index --watch CPU usage

Open
#1,046 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
53
Forks
18
Avg merge
3d 18h
Merged PRs (30d)
8

Description

The watcher which gets started by the VSCode or IntelliJ plugin (latest versions) constantly uses CPU even though nothing is happening, and sometimes burning lots of CPU time.

node --prof %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\@appland\appmap\built\cli.js index --watch --appmap-dir .
AppMaps processed: 0

node --prof-process isolate*.log output:

[Bottom up (heavy) profile]:
   ticks parent  name
  26086   91.6%  C:\WINDOWS\SYSTEM32\ntdll.dll
    277    1.1%    LazyCompile: *lstat node:fs:1490:15
    227   81.9%      LazyCompile: *Glob._processReaddir %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:368:43
    227  100.0%        LazyCompile: *Glob._process %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:295:36
    208   91.6%          LazyCompile: *<anonymous> %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:625:43
    208  100.0%            LazyCompile: *RES %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\inflight\inflight.js:18:28
     19    8.4%          LazyCompile: *Glob._processGlobStar2 %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:631:45
     19  100.0%            Function: ^<anonymous> %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:625:43
     19    6.9%      LazyCompile: *<anonymous> %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\readdirp\index.js:127:52
     19  100.0%        LazyCompile: *_read %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\readdirp\index.js:118:14
     19  100.0%          C:\Code\node-v18.13.0-win-x64\node.exe
     12    4.3%      LazyCompile: *Glob._readdir %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:525:36
     12  100.0%        LazyCompile: *Glob._process %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:295:36
     11   91.7%          LazyCompile: *<anonymous> %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:625:43
     11  100.0%            LazyCompile: *RES %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\inflight\inflight.js:18:28
      1    8.3%          LazyCompile: *Glob._processGlobStar2 %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:631:45
      1  100.0%            Function: ^<anonymous> %APPDATA%\Code\User\globalStorage\appland.appmap\node_modules\glob\glob.js:625:43

To me this looks like it's busy scanning the directories.
Also see https://github.com/getappmap/appmap-js/issues/969#issuecomment-1424739918.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the index --watch --appmap-dir . CLI entry point and reproduce the idle CPU usage using the profiling command shown. Inspect the watcher’s glob and readdirp activity identified in the profile; done means the watcher remains idle without continuously scanning directories or consuming substantial CPU.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.