Skip to content

Editing is very slow - about one second per keystroke #446

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
cosinekitty opened this issue Jul 9, 2015 · 31 comments
Closed

Editing is very slow - about one second per keystroke #446

cosinekitty opened this issue Jul 9, 2015 · 31 comments

Comments

@cosinekitty
Copy link

UPDATE - After I wrote the report below, editing suddenly became faster. It's still a little slow, but much better. I don't know what changed or how to make it happen again. :(

UPDATE 2 - 2015-07-17: I'm still finding Atom unusable for working on TypeScript... :( It's too slow. I type a few characters, then I have to wait for it to catch up with me. I'm switching back to WebStorm 10 for now. It's a shame because Atom is very nice in many other ways, but responsiveness is a critical requirement for an IDE.


Using atom-typescript 5.0.17 and Linter 1.2.0 or 1.2.3, I am now in a state where editing a particular TypeScript file is very slow. Every key I press takes about a full second for the editor to respond. There is no perceptible lag editing files other than this particular file, including C++ files, HTML, and even other TypeScript files.
Not sure it matters, but I'm running Debian Jessie after an upgrade from Debian Wheezy:

don@spearmint:~/flywheel$ uname -a
Linux spearmint 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux

The following may help repro the problem:

  • Clone my repository at: https://github.com/cosinekitty/flywheel
  • Open the directory with Atom.
  • Edit the file src/flywheel.ts
  • Start typing - everything is slow! (At least it is when I do it on my machine...)

If I can provide more info to diagnose/repro this problem, please let me know!

Thanks in advance...
Don

@Cu3PO42
Copy link
Member

Cu3PO42 commented Jul 9, 2015

Hello there!

The major culprits here would be the syntax highlighting and the TypeScript compiler running in the background to provide information about your code. Did this not happen in previous versions? As you may have noticed there was a big rewrite of the grammar used for syntax highlighting with the 5.0 release, it's probably more complex than the previous one by an order of magnitude, so a slightly bigger strain on the CPU is to be expected, however since a rule is only ever applied to a single line, performance shouldn't differ much between smaller and larger files.

I can notice no significant difference between this file and any other TypScript file in terms of performance, neither in terms of perceived performance, nor what is reported by the CPU profiler. I tried this on an instance running on Windows and one running on OS X. I don't have a Linux machine at hand to test, but I can't really imagine that being the issue.

Maybe you could post some screencaps with the profiler in them? Preferably both for this file and another TypeScript file that doesn't experience this issue?

Regards,
Cu3PO42

@cosinekitty
Copy link
Author

Hi Cu3PO42! Hopefully this is more legible than a screen shot. I figured out how to run the profiler (I'm new to Atom). I did some typing (mostly just editing comments) and noticed about a quarter of a second (subjective - don't know how to measure it) of lag each time I typed a key this time.

Here are the top few lines of the profile sorted in descending order on the "Self" column, which I assume is like the Exclusive Hits in Visual Studio profiler. I stopped on the row that fell below 1%.

34912.6 ms57.60 %   34912.6 ms57.60 %   (idle)  
12456.7 ms20.55 %   12463.7 ms20.56 %   /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/marker-index.js:206Node.dump    
2755.9 ms4.55 % 2755.9 ms4.55 % (garbage collector) 
2611.7 ms4.31 % 2611.7 ms4.31 % (program)   
430.6 ms0.71 %  430.6 ms0.71 %  get offsetHeight    

Here are the results sorting descending by "Total" (Inclusive Hits?). Again, I stopped when the number fell below 1%.

34912.6 ms57.60 %   34912.6 ms57.60 %   (idle)  
3.0 ms0.00 %    14587.7 ms24.07 %   /usr/share/atom/resources/app.asar/src/text-editor.js:1151module.exports.TextEditor.transact    
62.1 ms0.10 %   14584.7 ms24.06 %   /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:731module.exports.TextBuffer.transact    
3.0 ms0.00 %    13742.5 ms22.67 %   /usr/share/atom/resources/app.asar/node_modules/underscore-plus/lib/underscore-plus.js:73object.(anonymous function)    
2.0 ms0.00 %    13674.4 ms22.56 %   /usr/share/atom/resources/app.asar/src/text-editor.js:1981module.exports.TextEditor.mergeSelections 
0 ms0 % 13674.4 ms22.56 %   /usr/share/atom/resources/app.asar/src/text-editor.js:779module.exports.TextEditor.mutateSelectedText   
0 ms0 % 13674.4 ms22.56 %   /usr/share/atom/resources/app.asar/src/text-editor.js:1961module.exports.TextEditor.mergeIntersectingSelections 
0 ms0 % 13672.4 ms22.56 %   /usr/share/atom/resources/app.asar/src/text-editor.js:784(anonymous function)   
18.0 ms0.03 %   13621.4 ms22.47 %   /usr/share/atom/resources/app.asar/src/text-editor-component.js:3(anonymous function)   
375.5 ms0.62 %  13394.0 ms22.10 %   /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/marker-store.js:214module.exports.MarkerStore.createSnapshot    
0 ms0 % 12988.5 ms21.43 %   /usr/share/atom/resources/app.asar/src/text-editor-component.js:430module.exports.TextEditorComponent.onTextInput   
4.0 ms0.01 %    12881.3 ms21.25 %   /usr/share/atom/resources/app.asar/src/text-editor.js:718module.exports.TextEditor.insertText   
12456.7 ms20.55 %   12463.7 ms20.56 %   /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/marker-index.js:206Node.dump    
2755.9 ms4.55 % 2755.9 ms4.55 % (garbage collector) 
7.0 ms0.01 %    2729.9 ms4.50 % /usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:77module.exports.Emitter.emit  
2611.7 ms4.31 % 2611.7 ms4.31 % (program)   
2.0 ms0.00 %    2133.0 ms3.52 % /usr/share/atom/resources/app.asar/src/window-event-handler.js:179module.exports.WindowEventHandler.onKeydown   
4.0 ms0.01 %    2131.0 ms3.52 % /usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:315module.exports.KeymapManager.handleKeyboardEvent   
4.0 ms0.01 %    2100.0 ms3.46 % /usr/share/atom/resources/app.asar/src/command-registry.js:183module.exports.CommandRegistry.handleCommandEvent 
0 ms0 % 2100.0 ms3.46 % dispatchEvent   
0 ms0 % 2100.0 ms3.46 % /usr/share/atom/resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:511module.exports.KeymapManager.dispatchCommandEvent  
0 ms0 % 2100.0 ms3.46 % /usr/share/atom/resources/app.asar/src/command-registry.js:3(anonymous function)    
0 ms0 % 1887.7 ms3.11 % /usr/share/atom/resources/app.asar/src/text-editor-element.js:302newCommandListeners.(anonymous function)   
4.0 ms0.01 %    1689.4 ms2.79 % /usr/share/atom/resources/app.asar/src/view-registry.js:3(anonymous function)   
2.0 ms0.00 %    1584.3 ms2.61 % /usr/share/atom/resources/app.asar/src/view-registry.js:164module.exports.ViewRegistry.performDocumentUpdate    
1.0 ms0.00 %    1320.9 ms2.18 % /home/don/.atom/packages/linter/lib/messages.coffee:27(anonymous function)  
0 ms0 % 1320.9 ms2.18 % /home/don/.atom/packages/linter/lib/editor-linter.coffee:111(anonymous function)    
2.0 ms0.00 %    1317.9 ms2.17 % /home/don/.atom/packages/linter/lib/linter-views.coffee:55(anonymous function)  
0 ms0 % 1315.9 ms2.17 % /home/don/.atom/packages/linter/lib/linter-views.coffee:66LinterViews.render    
2.0 ms0.00 %    1092.6 ms1.80 % /usr/share/atom/resources/app.asar/src/text-editor.js:785(anonymous function)   
9.0 ms0.01 %    1089.5 ms1.80 % /usr/share/atom/resources/app.asar/src/text-editor-component.js:299(anonymous function) 
19.0 ms0.03 %   1079.5 ms1.78 % /usr/share/atom/resources/app.asar/src/text-editor-component.js:181module.exports.TextEditorComponent.updateSync    
0 ms0 % 1069.5 ms1.76 % /usr/share/atom/resources/app.asar/src/text-editor-element.js:306(anonymous function)   
1.0 ms0.00 %    1062.5 ms1.75 % /home/don/.atom/packages/atom-typescript/dist/main/atomts.js:98(anonymous function) 
2.0 ms0.00 %    1061.5 ms1.75 % /home/don/.atom/packages/atom-typescript/dist/main/atom/views/mainPanelView.js:380errorView.setErrors   
3.0 ms0.00 %    1038.5 ms1.71 % /usr/share/atom/resources/app.asar/src/selection.js:424module.exports.Selection.insertText  
3.0 ms0.00 %    1037.5 ms1.71 % /usr/share/atom/resources/app.asar/src/text-editor.js:744(anonymous function)   
17.0 ms0.03 %   962.4 ms1.59 %  /home/don/.atom/packages/atom-typescript/dist/main/atom/views/mainPanelView.js:398(anonymous function)  
2.0 ms0.00 %    949.3 ms1.57 %  /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:513module.exports.TextBuffer.setTextInRange  
17.0 ms0.03 %   946.3 ms1.56 %  /usr/share/atom/resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:552module.exports.TextBuffer.applyChange 
5.0 ms0.01 %    931.3 ms1.54 %  /home/don/.atom/packages/linter/lib/linter-views.coffee:164LinterViews.renderPanelMarkers   
1.0 ms0.00 %    827.2 ms1.36 %  /home/don/.atom/packages/atom-typescript/dist/main/atom/views/lineMessageView.js:10LineMessageView  
13.0 ms0.02 %   825.2 ms1.36 %  /home/don/.atom/packages/atom-typescript/dist/main/atom/views/view.js:9View 
19.0 ms0.03 %   770.1 ms1.27 %  /usr/share/atom/resources/app.asar/src/text-editor-presenter.js:102module.exports.TextEditorPresenter.getState  
13.0 ms0.02 %   728.0 ms1.20 %  /usr/share/atom/resources/app.asar/node_modules/atom-space-pen-views/node_modules/space-pen/lib/spa…:142View  
13.0 ms0.02 %   672.0 ms1.11 %  /home/don/.atom/packages/linter/lib/linter-views.coffee:172(anonymous function) 
22.0 ms0.04 %   649.9 ms1.07 %  /home/don/.atom/packages/linter/lib/views/bottom-panel.js:34updateMessages  
16.0 ms0.03 %   603.9 ms1.00 %  /home/don/.atom/packages/linter/lib/views/bottom-panel.js:40(anonymous function)    
2

Does this help?

@cosinekitty
Copy link
Author

The very slow editing came back. This time the majority of CPU while I was typing was non-idle! I drilled down into the most expensive call stack and took a screen shot this time so you can see the hierarchy. Please let me know if there is something else I can do to help.

atom-slow-edit-1

@cosinekitty
Copy link
Author

Is anyone looking into this? I'm still finding Atom unusable for working on TypeScript... :( It's too slow. I type a few characters, then I have to wait for it to catch up with me. I'm switching back to WebStorm 10 for now. It's a shame because Atom is very nice in many other ways, but responsiveness is a critical requirement for an IDE.

Is there anything further I can do to help diagnose or fix this issue?

@Cu3PO42
Copy link
Member

Cu3PO42 commented Jul 17, 2015

I've been trying to figure this out. However I don't get the same issue, also my time is extremely limited right now. The order of CPU consuming tasks is roughly the same for me, however it's a lot faster and more responsive overall. Since I can't reproduce this properly, I don't really know where the problem lies either.

I doubt your PC is just too slow to handle Atom, since WebStorm seems to work fine.

I'll get back to you once I do manage to figure this out. Sorry this isn't working properly for you right now.

@cosinekitty
Copy link
Author

Thank you, Cu3PO42! I will take a whack at it over the weekend, even though I have never worked on Atom code before. Will update here if I discover anything interesting.

@basarat
Copy link
Member

basarat commented Jul 17, 2015

Start typing - everything is slow! (At least it is when I do it on my machine...)

Can't reproduce it either.

  • Are you working off the local file system or network?
  • What other plugins do you have?
  • Have you tried uninstalling and reinstalling atom with 0 plugins ... is atom slow on its own?
  • Just install atom-typescript ... now open a ts file ... did atom-typescript make the editing experience slow?

My screen grab:

meh

Thanks 🌹

@cosinekitty
Copy link
Author

Hi basarat,

I completely uninstalled Atom, deleted my ~/.atom folder, reinstalled Atom 1.0.2, and re-adjusted all my settings the way I like. Now everything is very fast! I don't know what got screwed up, but it is working fine now. Thanks for taking a look, and I'm sorry for the distraction...

  • Don

@basarat
Copy link
Member

basarat commented Jul 18, 2015

Thanks for taking a look, and I'm sorry for the distraction

Never an issue. Thanks for your patience. BTW nice book : http://cosinekitty.com/raytrace/contents.html respect 🙇

@omidkrad
Copy link

It's also unbearably slow for me. In a project with about 10 .ts files it takes more than 5 minutes from when I make a key stroke until I get the first signs of intellisense! This is on a very fast PC. I tried uninstalling atom and configurations and reinstalling to no avail. 😞

Also when there is a warning or error message, it disappears so fast that I can never read it. I only see a yellow or red pop up coming and going.

@basarat
Copy link
Member

basarat commented Sep 15, 2015

@omidkrad can you share your tsconfig + directory tree showing tsconfig.json and node_modules (if any)

@omidkrad
Copy link

This is my tsconfig.json

{
  "compilerOptions": {
    "module": "amd",
    "target": "ES5",
    "noImplicitAny": true,
    "noEmitOnError": false,
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true
  }
}

node_modules is really large. It contains 587 folders. Maybe that's why it's so slow?

Now I remember I might have used flatten-packages on this. Let me delete all modules and npm install again.

@basarat
Copy link
Member

basarat commented Sep 15, 2015

@omidkrad alternatively move tsconfig.json to a some directory inside e.g src

@omidkrad
Copy link

npm install brought back all those 587 directories, but moving tsconfig.json worked!!!

Now I feel I'm in a 🚀!! 👍

@basarat
Copy link
Member

basarat commented Sep 15, 2015

I should probably add #332 to the faq https://github.com/TypeStrong/atom-typescript/blob/master/docs/faq.md

@johnnyreilly
Copy link
Member

For what it's worth it's rocket fast for me @basarat! 🌷

@johnnyreilly
Copy link
Member

(My tsconfigs are all in subdirectories)

@mgiraldo
Copy link

this is craaazy slow for me too... a very simple static project with a single .ts file that references three d.ts files. I set compileOnSave : false because I have tsc watching the file already

going back to sublime for now

@jcmoore0
Copy link

jcmoore0 commented Mar 2, 2016

It is much faster after I excluded the tmp and dist directories in tsconfig.json
"exclude": [
"node_modules",
"src/lib",
"typings/main",
"typings/main.d.ts",
"dist",
"tmp"
],

@schmitzhermes
Copy link

Hey all,

I am facing the same issue... typing (0.5 secs per keystroke) and autocompletion (~ 5 secs) are really slow. I am using the following angular project: https://github.com/mgechev/angular2-seed

I already did the following things:

  • deleted Atom.app and ~/.atom folder, reinstalled atom and ran it "plain" (i.e. just with atom-typescript and linter installed)
  • moved tsconfig.json to the src/ subdirectory in order to not have "node_modules" indexed
  • deleted the entire "node_modules" folder (obviously this is not a good idea...), but still: extremely slow

Another information: other files work just fine, just *.ts are that slow.

Are you guys using the latest version of Atom (i.e. 1.6)?

Maybe you guys can help me. Let me know if I can provide something useful that helps digging into this issue.

Cheers,
Jan

@cpylua
Copy link

cpylua commented Mar 25, 2016

I had the same issue when trying TypeScript, I have only one ts files, but atom reacts really slow. It shows hundreds of pending requests whenever I type and autocompletion is totally unusable.

Excluding packages(node_modules, etc.) worked for me as suggested by @jcmoore0.

@schmitzhermes
Copy link

hmmm.. I did that as well, changed nothing.
What actually made it a little bit faster was moving the tsconfig.json in the src directory (obviously it has no "node_modules" in its "path" then). But still: @basarat Screen-GIF is (unless it's in 1.5x speed) very impressive. My performance is way slower.

@anderflash
Copy link

Same for an Angular-CLI based project. In Sublime, we don't wait for the autocomplete panel to appear.

@stewhouston
Copy link

+1

It would be nice to figure out where the bottlenecks are occurring as this issue is grinding my workflow to a halt.

@asfernandes
Copy link

Excluding node_modules resolves the slowness, but on the other hand we loose the @types from things like module.id and describe, beforeEach, etc in a Angular 2 project. Sublime and vscode works with node_modules without being slow.

@stewhouston
Copy link

@asfernandes Thanks, just leaving a note for anyone who might stumble across this as it can be a real source of frustration.

I fixed the issue by being very thorough when settings the "excludes" fields in my tsconfig.json. One of my directories had its own node_modules directory which had 50+ packages installed. I added this directory to the "excludes" array and now atom-typescript runs near instantaneously, even in my bulky project.

You may still lose some of the functionality as mentioned by @asfernandes above, however this is certainly a compromise I'm willing to make to eliminate the unbearably slow processing.

@asfernandes
Copy link

@stewhouston and others, it became usable for me with this:

	"filesGlob" : [
		"**/*.ts",
		"!dist/**",
		"!node_modules/**",
		"node_modules/@types/**/*.d.ts",
		"node_modules/@angular/**/*.d.ts"
	],

@otoomey
Copy link

otoomey commented Jan 11, 2017

I was using atom as well for typescript and it was painstakingly slow. I would add console.log() to a line, atom would stop and think for about 20 seconds while saying that there were errors everywhere until it caught up. Then I would save and it would take another 20 seconds or so to compile my code. I have switched to VS Code now, and the speed is no comparison. IntelliSense is instantaneous and compiling takes about 2 seconds. I used the exact same tsconfig (it's the one from the angular2 quickstart seed) in both editors:
{ "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ "es2015", "dom" ], "noImplicitAny": true, "suppressImplicitAnyIndexErrors": true } }

I'm using Ubuntu 16.04 LTS, a 2nd gen i5 and 8GB RAM. Adding exclude ["node modules"] does next to nothing.

I've honestly given up and don't even feel it would be worth the time to solve, so that I could use Atom instead of VS Code. So far, for typescript anyway, microsoft's editor has been a much better experience.

@phil-neumiller
Copy link

I have all of a sudden seen Atom slow to a crawl on Windows 10. I just installed Norton thought maybe that was it, but I turned off everything in Norton and its still slower than a dog pooping.

@guncha
Copy link
Contributor

guncha commented Jan 21, 2017

Please try the beta from this PR - #1166. It should be much faster.

@Yugloocamai
Copy link

I have found that with larger projects atom-typescript is far, far too slow to use...

@TypeStrong TypeStrong locked and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests