Skip to content

40% CPU and Gigs of memory used parsing a map #20279

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
mjbvz opened this issue Nov 27, 2017 · 3 comments
Closed

40% CPU and Gigs of memory used parsing a map #20279

mjbvz opened this issue Nov 27, 2017 · 3 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Nov 27, 2017

From @bootstraponline on November 23, 2017 1:25

  • VSCode Version: 1.18.1
  • OS Version: Windows 10 Version 1709 (OS Build 16299.19)

Steps to Reproduce:

  1. git clone https://github.com/bootstraponline/hex.git
  2. git checkout dbf422b1856d054b01bd28193ca52ed9c4033ceb
  3. Open hex/ts/ in Visual Studio Code
  4. Change anything in the TypeScript files
  5. Observe gigs of memory used.

image

image

Reproduces without extensions: Yes

I have a large map. That appears to make TypeScript crazy. I'm not sure if there's a way to disable processing on a per file basis. This issue does not happen when using JSON instead of a map.

export let codes = new Map([
   ['03310001', ['Potion', 'Battle Items [0]', true]],
   // ...
]);

Copied from original issue: microsoft/vscode#38993

@mjbvz mjbvz self-assigned this Nov 27, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented Nov 27, 2017

From @KuromiAK on November 26, 2017 0:28

Change the code in this way seems to help?

export let codes = new Map<string, [string, string, boolean]>([
   ['03310001', ['Potion', 'Battle Items [0]', true]],
   // ...
]);

@mjbvz
Copy link
Contributor Author

mjbvz commented Nov 27, 2017

From @bootstraponline on November 26, 2017 3:9

This helped the most. I'm not sure what causes gigs of memory usage. Maybe giant arrays in the constructor is an edge case.

// Use map to preserve iteration order. Object.keys is undefined
export let codes: Map<string, [string, string, boolean]> = new Map();
export function initCodes() {
  if (codes.size > 0) { return; }

  codes.set('03310001', ['Potion', 'Battle Items [0]', true]);
  codes.set('74500001', ['Power Ex', 'Battle Items [0]', true]);
  
...

@mjbvz mjbvz added VS Code Tracked There is a VS Code equivalent to this issue and removed typescript labels Nov 27, 2017
@mjbvz mjbvz removed their assignment Nov 27, 2017
@mjbvz
Copy link
Contributor Author

mjbvz commented Nov 27, 2017

I confirmed that the TS Server process has the high cpu usage. The server logs don't have any helpful info

@mhegazy mhegazy added the Bug A bug in TypeScript label Nov 27, 2017
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Nov 27, 2017
@mhegazy mhegazy assigned ahejlsberg and unassigned sandersn Nov 28, 2017
@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Dec 1, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

4 participants