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

Large file under git control encoding guess can freeze the editor #87205

Closed
ziggi opened this issue Dec 17, 2019 · 10 comments
Closed

Large file under git control encoding guess can freeze the editor #87205

ziggi opened this issue Dec 17, 2019 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues git GIT issues verified Verification succeeded
Milestone

Comments

@ziggi
Copy link

ziggi commented Dec 17, 2019

  • VSCode Version: 1.41 (same on 1.42 insiders build too)
  • OS Version: Windows 10 Pro 1909, build 18363.535

Steps to Reproduce:

  1. Open a large file (my file is 93k+ lines, 3.96 MiB) and a small one. The files should be in Windows 1251 encoding and VS Code settings.json should contains "files.autoGuessEncoding": true,.
  2. Switch tab from small to large.

Does this issue occur when all extensions are disabled?: Yes

It looks like the problem is in jschardet, it was updated from 1.6.0 to 2.1.1.

CPU-20191218T010956.cpuprofile.txt
Profile-20191218T010523.json.txt

image
image

@dbaeumer dbaeumer added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Dec 18, 2019
@bpasero
Copy link
Member

bpasero commented Dec 18, 2019

@ziggi great analysis, wanna report it to jschardet maybe?

@bpasero bpasero added file-guess-encoding upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Dec 18, 2019
@ziggi
Copy link
Author

ziggi commented Dec 18, 2019

I'm not 100% sure what the problem is in jschardet. The problem may be in vscode only.

@bpasero
Copy link
Member

bpasero commented Dec 18, 2019

@ziggi looks like jschardet to me. We are simply calling this method:

const guessed = jschardet.detect(buffer);

@ziggi
Copy link
Author

ziggi commented Dec 18, 2019

Ok, done: aadsm/jschardet#53

@bpasero bpasero added the upstream-issue-linked This is an upstream issue that has been reported upstream label Dec 18, 2019
@creative-acr
Copy link

I have the same issue while opening large JS file after updating to version 1.41.1

vs code issue

@bpasero
Copy link
Member

bpasero commented Jan 4, 2020

@creative-acr do you have "files.autoGuessEncoding": true configured which this issue is about?

@bpasero bpasero changed the title Freezes on large (Windows 1251 && files.autoGuessEncoding = true) files after 1.41 update Large file encoding guess can freeze the editor Jan 5, 2020
@bpasero
Copy link
Member

bpasero commented Jan 5, 2020

@ziggi to clarify, you only see this with large files that are under git control?

@ziggi
Copy link
Author

ziggi commented Jan 5, 2020

@bpasero yes

@bpasero bpasero added the git GIT issues label Jan 6, 2020
@bpasero
Copy link
Member

bpasero commented Jan 6, 2020

I can reproduce and it looks like the dirty diff decorator is triggering this (probably ever since we moved to git-fs recently). Though I cannot explain why this performance issue does not show up when just opening the editor where we also guess the encoding. Maybe the diff decorator is not as optimized as the code editor model that reads the file in chunks and reads the file entirely?

@joaomoreno steps to reproduce: aadsm/jschardet#53 (comment)

@bpasero bpasero removed upstream Issue identified as 'upstream' component related (exists outside of VS Code) upstream-issue-linked This is an upstream issue that has been reported upstream labels Jan 6, 2020
@bpasero bpasero added this to the January 2020 milestone Jan 6, 2020
@bpasero bpasero changed the title Large file encoding guess can freeze the editor Large file under git control encoding guess can freeze the editor Jan 6, 2020
@bpasero bpasero closed this as completed in 626049a Jan 6, 2020
@bpasero bpasero added the bug Issue identified by VS Code Team member as probable bug label Jan 6, 2020
@bpasero
Copy link
Member

bpasero commented Jan 6, 2020

I pushed a fix that will limit the buffer for encoding guessing to 65kb. The dirty diff decorator was passing the entire buffer. Filed #88119 as follow up.

@connor4312 connor4312 added the verified Verification succeeded label Jan 30, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues git GIT issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

6 participants