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

2.5gb on small project #28540

Closed
edunsouza opened this issue Nov 11, 2018 · 11 comments
Closed

2.5gb on small project #28540

edunsouza opened this issue Nov 11, 2018 · 11 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue

Comments

@edunsouza
Copy link

I have a small project of Natural Language Processing and there are 2 files with 37k lines, which contains the datasets. The problem occurs even when i'm not using those files. Not even opening the files. I have to use other editor to run "node index.js" -my main fail.

I dont know how the problem starts, but when i open the vscode editor, it goes up to 2.5gb of ram on the startup. I dont know what is happening.

@chrmarti
Copy link

/needsMoreInfo

What is the file type of the data files?

@chrmarti chrmarti self-assigned this Nov 12, 2018
@vscodebot
Copy link

vscodebot bot commented Nov 12, 2018

Thanks for creating this issue! We figured it's missing some basic information or in some other way doesn't follow our issue reporting guidelines. Please take the time to review these and update the issue.

Happy Coding!

@edunsouza
Copy link
Author

/needsMoreInfo

What is the file type of the data files?

They are all javascript and json files.
Vscode takes a while to shoot up the memory. When it does, the ram usage goes up to 2.5gb and starts to freeze some features.

@chrmarti
Copy link

Does it reproduce when starting with code --disable-extensions?

@edunsouza
Copy link
Author

edunsouza commented Nov 13, 2018 via email

@chrmarti chrmarti assigned mjbvz and unassigned chrmarti Nov 13, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Nov 14, 2018

@edunsouza Can you share those source files?

@edunsouza
Copy link
Author

@mjbvz of course I can! And I'll be happy if I can help to find out the problem.

The files are available on the repository: https://github.com/edunsouza/communicator

@mjbvz mjbvz transferred this issue from microsoft/vscode Nov 15, 2018
@mjbvz
Copy link
Contributor

mjbvz commented Nov 15, 2018

Tested using typescript@3.2.0-dev.20181114

Switching between the js files in dataset/ I can still easily get up to over a GB. Seems mostly to happen after switching to another js file not under dataset.

Logs:
tsserver.log

@mjbvz mjbvz removed their assignment Nov 15, 2018
@DanielRosenwasser DanielRosenwasser added Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior labels Nov 15, 2018
@DanielRosenwasser
Copy link
Member

@sandersn and @ahejlsberg, any ideas on how we could do better here?

@ahejlsberg
Copy link
Member

The issue looks to be with the dataset/afinn/afinn.js file. It contains an array literal with 30K+ elements specified as object literals:

module.exports = [
    {texto: ";)", sentimento: 1, ";)": 1},
    {texto: ";@", sentimento: -1, ";@": -1},
    {texto: ";*", sentimento: -1, ";*": -1},
    {texto: ";**", sentimento: -1, ";**": -1},
    {texto: ";~", sentimento: -1, ";~": -1},
    ...
];

The reverse mapping pattern means that each object literal has a unique type. To make matters worse, object literal normalization (#19513) causes us to expand into 30K+ unique types with 30K+ properties each (!!!). We then attempt to perform subtype reduction on the set of types in order to make a union type. This ends up generating enormous amounts of work. If I reduce down to 2500 unique types we still take close to 30 seconds to type check, so with 30K+ types we'll effectively take forever.

I'm thinking we should consider a governor on union subtype reduction. Given that is an O(n^2) operation, perhaps we limit subtype reduction to unions with 500 or less constituents.

@ahejlsberg
Copy link
Member

Oops, meant to close the old PR, not the issue.

@ahejlsberg ahejlsberg added the Fixed A PR has been merged for this issue label Jan 29, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Performance Reports of unusually slow behavior Fixed A PR has been merged for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants