Quramy / tsuquyomi

A Vim plugin for TypeScript
http://www.vim.org/scripts/script.php?script_id=5151
1.39k stars 72 forks source link

One instance of tsserver for each instance of vim? #277

Open djvs opened 5 years ago

djvs commented 5 years ago

Is there a way to optimize this? It's taking mountains of RAM.

mnzaki commented 5 years ago

I think how much RAM you save depends on how much memory overhead each tsserver instance adds. I would make a blind guess and say that most of the memory is being used to hold information about the actual source code. Do you want to optimize opening multiple vim instances over the same source code tree?

djvs commented 5 years ago

Yes, exactly.

mnzaki commented 5 years ago

I took a very brief look at the tsserver protocol, there seem to be request/response sequence numbers, and tsuquyomi seems to be keeping a global sequence number and incrementing by 1 for each request/response. This would require some work around to get multiplexing working

I think one way to share the server would be to simply store the PID of tsserver in some .dotfile, and on startup check if the .dotfile exists and whether the process is still running and just rewire stdin/stdout basically. This could be done from tsuquyomi, but maybe some bash script wrapper around tsserver, or even an npm module, might be nicer and reusable by other projects.

On the tsuquyomi side perhaps it is enough to simply update the current sequence number when receiving an out-of-sequence message. What it currently does is just drop the message if the sequence number does not match the expected one.

But anyways, I feel like a better "solution" would probably be to make use of the tabs and windows in vim more effectively and avoid multiple instances on the same source code tree :smile: