The Wayback Machine - https://web.archive.org/web/20220107121458/https://github.com/codota/TabNine/issues/43
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

High memory and CPU usage #43

Closed
dotdash opened this issue Dec 20, 2018 · 70 comments
Closed

High memory and CPU usage #43

dotdash opened this issue Dec 20, 2018 · 70 comments

Comments

@dotdash
Copy link

@dotdash dotdash commented Dec 20, 2018

While working on rustc, I noticed TabNine and rls regularly consuming 100% CPU each for quite a while. I usually only notice it when I switch to a different virtual desktop when I build rustc, so it's not only while actually working in vim, but also(?) a while after I stop changing things.

Additionally, the memory usage for TabNine is huge. Currently top shows:

23316 doener 20 0 9964048 4,9g 0 S 0,0 31,2 74:41.38 TabNine

The process was started about 86 hours ago.

@dotdash dotdash changed the title Hgih memory and CPU usage High memory and CPU usage Dec 20, 2018
@zxqfl
Copy link
Collaborator

@zxqfl zxqfl commented Dec 20, 2018

Does it continue after the build stops? This is possibly caused by TabNine picking up all the filesystem events from the build.

That's a lot of memory, a normal amount of usage is 500MB-1GB. Does it go back to a more reasonable level if you restart your editor or type TabNine::restart?

@doron-cohen
Copy link

@doron-cohen doron-cohen commented Jan 6, 2019

I have this issue when checking out between versions while working on Python. when the versions are very different from each other I assume TabNine is rebuilding it's DB but the CPU usage is insane making my laptop almost unusable.

It would be very convenient to have a CPU / RAM limit configuration

@ovidiucs
Copy link

@ovidiucs ovidiucs commented Jan 24, 2019

image

This is on archlinux.

@taylorlapeyre
Copy link

@taylorlapeyre taylorlapeyre commented Feb 20, 2019

Using over 3GB of memory on my machine:

screen shot 2019-02-19 at 4 30 19 pm

@tommoor
Copy link

@tommoor tommoor commented Feb 20, 2019

I love the functionality TabNine brings, but having to uninstall until this issue is somewhat resolved 😢

image

@taylorlapeyre
Copy link

@taylorlapeyre taylorlapeyre commented Feb 26, 2019

@zxqfl Hey there! I was wondering if you have any updates on whether this is something you are working on, something you are currently fixing, or if this is more of a "no fix" kind of situation.

As a paying customer, I just want to know where the author stands on this!

@n3bulous
Copy link

@n3bulous n3bulous commented Mar 6, 2019

Same issue here re: memory. 3G for a fairly small java/groovy project.

@Deewiant
Copy link

@Deewiant Deewiant commented Mar 13, 2019

EDIT: tabnine --version reports TabNine 1.0.10 (x86_64-unknown-linux-gnu).

A fairly simple, though heavy, test case for both this and #24 (they seem like the same issue to me) is OpenWrt. I did a clean checkout of current master (commit 2407b1edccc2f2d426333bd7cc1743c8e4da8dbd) there and ran TabNine manually, asking it for one completion in the OpenWrt source directory, as follows (I pieced this together based on company-tabnine, is there API documentation somewhere?):

$ ./TabNine
{"version": "0.11.1", "request": {"Autocomplete": {"filename": "/path/to/openwrt/Makefile", "before": "hi", "after": "", "region_includes_beginning": false, "region_includes_end": false, "max_num_results": 10}}}
{"suffix_to_substitute":"hi","results":[],"promotional_message":[]}

I left it hanging there since I just needed to point it to the OpenWrt directory.

This gave me 100% CPU usage for eight seconds to start with, which is fair enough since it's indexing the whole directory for the first time. Memory usage stabilizes at around 300 megabytes (looking at the "RES" column in htop). Then I followed up with building OpenWrt in another shell, using the default configuration because that suffices to exhibit this issue, and with eight CPU cores to make it not take forever (and nice -n19 because I wanted the rest of my system to not suffer too much):

make defconfig
nice -n19 make world -j8

For some background, OpenWrt is a Linux distribution for embedded devices — routers in particular. Its build system first builds "tools", which include basic things like tar and sed, then the "toolchain" i.e. gcc and company, before it goes on to actually build the whole system.

Of TabNine, I can observe all of the following during even just the "tools" build:

  • Memory usage growing above 1000 megabytes
  • CPU usage hovering around 10–40% but occasionally spiking as high as 300%
  • A peek at strace showing that TabNine is doing all kinds of stuff including calling inotify_add_watch in the build_dir directory, which I should note is under .gitignore

After the "toolchain" build completes, memory usage is at almost 2500 megabytes and user CPU time (as shown by htop) is at about 19 minutes. Since the build has taken around 30 minutes so far, this is over 60% average CPU usage.

In the end, the entire build took me just shy of 44 minutes. At that point TabNine's CPU time stabilized at 40 minutes and memory usage at nearly 4500 megabytes. I think it's fair to call both of these "high usage". Normally at this point I'd pkill TabNine until it bloats up again, but sometimes I've missed it until it's grown to eat so many gigabytes that it's actually causing trouble for the rest of my system.

This time I also took a look at the number of inotify watches TabNine has registered:

$ grep -c inotify /proc/27260/fdinfo/7
27118

That definitely seems incorrect. Based on this and what I saw with strace, I'd wager that there's a bug related to processing of .gitignore and similar files: If an entire directory is ignored, I don't think TabNine should be recursing into it and especially not adding inotify watches therein. That might be the sole cause of both the CPU and the memory usage.

@zxqfl
Copy link
Collaborator

@zxqfl zxqfl commented Mar 13, 2019

Thank you for the detailed investigation and analysis. Indeed, TabNine places a watch on every subdirectory, even those which match patterns in .gitignore. This is because the library which TabNine uses to watch directories (notify) and the library which it uses to identify ignored paths (ignore) are different.

I guess the best way to fix this issue will be for TabNine to still use ignore, but to handle recursing into sub-directories itself, allowing it to avoid recursing into .gitignored directories.

PS: You can find API documentation here.

@zxqfl
Copy link
Collaborator

@zxqfl zxqfl commented May 16, 2019

I reproduced the high memory usage when building OpenWrt. Today I released an update to TabNine which uses 0% CPU while building OpenWrt. The new behaviour is as follows:

  • TabNine initially places a recursive watch on the project root.
  • Whenever TabNine receives a change notification for an ignored path and the notification comes from a recursive watch on a path P, the recursive watch on P is replaced with a non-recursive watch on P and a recursive watch on all non-ignored immediate children of P.

The update is currently available to beta testers. To try it, type TabNine::become_beta_tester, then type TabNine::version to check you have the new version -- the new version number is 1.0.14.

If no beta testers report issues, I'll release it to all users soon.

Thanks again for investigating!

@zxqfl zxqfl closed this in aa5f027 May 16, 2019
@zxqfl
Copy link
Collaborator

@zxqfl zxqfl commented May 16, 2019

Closing for now, please re-open if the problem persists.

@superDuperCyberTechno
Copy link

@superDuperCyberTechno superDuperCyberTechno commented Sep 2, 2019

2.1.17 is consuming 3.3 GB of memory (and counting), ~35% CPU. Been running for an hour or so.

@moritz
Copy link

@moritz moritz commented Sep 8, 2019

Can confirm, tabnine 2.1.17 with vim consumes several GB if I leave it open with a few python tabs.

Some of my python projects contains venv directories with virtualenvs that contain quite a few python files, no idea if this related.

@zxqfl please reopen, or should I open a new bug?

@QLaille
Copy link

@QLaille QLaille commented Sep 17, 2019

Problem is persisting with TN taking 20% of my RAM at start, and can go up to soft-locking the PC after 45 minutes or so. Fortunately my Fan runs like crazy when I'm close to 100% resources used.
Version 2.1.11 for VSCode.

@doggyeh
Copy link

@doggyeh doggyeh commented Sep 19, 2019

You can switch to old version which doesn't have this problem for now.
For example, I'm using vim.
git clone https://github.com/zxqfl/tabnine-vim ~/.vim/bundle
cd ~/.vim/bundle/tabnine-vim
git checkout c20d73f3e007d4b8804c344f114eb03b5c9466a3

This version doesn't have the CPU/MEM problem for me.

@ilAYAli
Copy link

@ilAYAli ilAYAli commented Sep 19, 2019

I just checked top on my development machine (v. 2.1.17):

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
32001 petter    20   0   20.4g  20.0g  11400 S 175.8  63.8 276:55.62 TabNine

20GB resident memory(!)

@QLaille
Copy link

@QLaille QLaille commented Sep 20, 2019

You can switch to old version which doesn't have this problem for now.
For example, I'm using vim.
git clone https://github.com/zxqfl/tabnine-vim ~/.vim/bundle
cd ~/.vim/bundle/tabnine-vim
git checkout c20d73f3e007d4b8804c344f114eb03b5c9466a3

This version doesn't have the CPU/MEM problem for me.

I'll see what I can do with VSC (sorry, not very fond of vim :p ) and keep you in touch

@QLaille
Copy link

@QLaille QLaille commented Sep 29, 2019

I can confirm that TabNine V2.1.7 is stable on VSCode and doesn't take a whole lot of resources.

@validatedev
Copy link

@validatedev validatedev commented Oct 3, 2019

TabNine 2.1.17 uses 1.5 GB of the memory at the initial. Is this the expected behaviour? Isn't it so much?

@CDitzel
Copy link

@CDitzel CDitzel commented Oct 8, 2019

using TabNine within emacs and the company package leads to an initial memory usage of 3 GB which increases over time. I now disabled the local support and try the cloud facility

@shamoons
Copy link

@shamoons shamoons commented Nov 11, 2019

How do I downgrade to 2.1.17 with VS Code (windows WSL)

@VinSpee
Copy link

@VinSpee VinSpee commented Nov 21, 2019

Hi! I hit an all-time record this morning:

44GB memory

@moritz
Copy link

@moritz moritz commented Nov 21, 2019

@zxqfl could you please re-open this issue? It still seems to be a problem for a lot of people (me included).

@tmpm697
Copy link

@tmpm697 tmpm697 commented Nov 28, 2019

auto completion that took roughly 10GB when perform is not cool. will try later :)

@Seybo
Copy link

@Seybo Seybo commented Dec 3, 2019

image

@dialguiba
Copy link

@dialguiba dialguiba commented Sep 7, 2020

image
Same here :(

@charlie0077
Copy link

@charlie0077 charlie0077 commented Oct 11, 2020

I had to uninstall tabnine because of of this. I usually have more than 6 vscode project open. 6*2G = 12G.

@mkubdev
Copy link

@mkubdev mkubdev commented Oct 12, 2020

Excessive memory usage on Windows 10 with VSCode's extension.. ~1/1.5G. I'm not experiencing any crash and BSOD but it's too heavy to use..

@ghost
Copy link

@ghost ghost commented Oct 15, 2020

Why is 1GB of usage in the first place? Could we limit it like max_memory_usage = 512M or max_cpu_usage=20% keeping performance?

@Picoseconds
Copy link

@Picoseconds Picoseconds commented Oct 15, 2020

AI uses a lot of memory.

@solidstatejake
Copy link

@solidstatejake solidstatejake commented Oct 20, 2020

I really like Tabnine. It allows vscode to function like an IntelliJ-based IDE, but I can’t even press tab for autocomplete (i.e. Emmet), or manually format my code when it’s on.

@RenanFG
Copy link

@RenanFG RenanFG commented Oct 22, 2020

same, at project start already 1gb memory, after 200 lines of code 1.5gb..

@mkhasson97
Copy link

@mkhasson97 mkhasson97 commented Nov 26, 2020

Same problem!, Tabnine uses a lot of RAM

@AkdenizKutayOcal
Copy link

@AkdenizKutayOcal AkdenizKutayOcal commented Nov 27, 2020

I love the VSCode extension but it is already consuming 1.5G after 100 lines of code. I hope it will be fixed at some point.

@WilliamD47
Copy link

@WilliamD47 WilliamD47 commented Feb 3, 2021

Still an issue in 2021; using 2GB ram on a python project with a couple hundred lines of code. I'm using a mac

@asheroto
Copy link

@asheroto asheroto commented Feb 18, 2021

High memory issues occur on my machine too. Language agnostic. It's the highest memory consuming process on my computer. Ha!

@Philwi
Copy link

@Philwi Philwi commented Feb 18, 2021

Got some huge amount of memory consumption as well. Will uninstall until its fixed...

@ahmad-ali14
Copy link

@ahmad-ali14 ahmad-ali14 commented Mar 22, 2021

same here, it's almost passing Google chrome with 20 open tabs.

@multiwebinc
Copy link

@multiwebinc multiwebinc commented Apr 14, 2021

Why is this issue closed if it's obviously still a problem.

@Limatucano
Copy link

@Limatucano Limatucano commented Jun 10, 2021

I also have this problem, but for me it's more controlled
image

Has anyone found the solution?

@mkubdev
Copy link

@mkubdev mkubdev commented Jun 11, 2021

@Limatucano I was struggling at ~1.5gb. I'm at ~500mb like you now. For me it's a good improvment...

@ruv
Copy link

@ruv ruv commented Jun 17, 2021

A possible workaround is to limit the memory (and maybe CPU) for the editor and all its sub-processes (i.e., for the process tree).

In Windows, something like Process Governor can be used.

@asheroto
Copy link

@asheroto asheroto commented Jun 19, 2021

Indeed that is a workaround, but this is absolutely an issue within TabNine. There are numerous reports of this problem, and even after reinstalling Windows the issue persists.

@Limatucano
Copy link

@Limatucano Limatucano commented Jun 20, 2021

Yeah, we dont need to find a workaround, because they need to resolve this issue. And i dont understand why this issue its closed

@mkubdev
Copy link

@mkubdev mkubdev commented Jun 21, 2021

Is ~500mb too much for you guys ? @2020 we struggled with 1,5Gb... 500mb is fine for AI.

@ilAYAli
Copy link

@ilAYAli ilAYAli commented Jun 21, 2021

500MB? I gave up on the plugin when it used > 20GB of resident RAM!
The RAM usage is probably proportional to the size of the indexed code and available RAM.

@mkubdev
Copy link

@mkubdev mkubdev commented Jun 21, 2021

@ilAYAli Yes! I'm running VSCode from WSL2 and i have no problem anymore with TabNine ! To be honest, I don't know if this is optimization from codata, or it's because i recently add a memory limitation to my WSL2 instance...

To add memory limitation to $wsl2 :

  1. Create a file at %UserProfile%/.wslconfig
  2. Set config :
[wsl2]
memory=6GB # Limits VM memory in WSL 2 to 6 GB
/*processors=5 # Makes the WSL 2 VM use two virtual processors*/

2

@asheroto
Copy link

@asheroto asheroto commented Jun 22, 2021

@mkubdev your WSL instance is a Windows-based one?

@talcodota
Copy link

@talcodota talcodota commented Jun 22, 2021

500MB? I gave up on the plugin when it used > 20GB of resident RAM!
The RAM usage is probably proportional to the size of the indexed code and available RAM.

Hey @ilAYAli,
This should never happen.
Can you please share your logs, so we can investigate this?
type tabnine::logs inside your IDE and send us the log files to [email protected]
Also, name the IDE and the operating system you are using.

Thank you.

@ilAYAli
Copy link

@ilAYAli ilAYAli commented Jun 22, 2021

@talcodota thank you for your feedback, but I am not using the plugin anymore.
It is even possible that the problem is solved as it is quite some time since I used it (6+ months).
It was not an IDE, but vim or neovim on a Linux development server.

@eo1989
Copy link

@eo1989 eo1989 commented Aug 20, 2021

Has this crap been resolved? I had to remove t9 from my neovim workflow because it was making the entire mac unusable. It was the newest version available. masOS 10.15.7.

@MatiasEsf
Copy link

@MatiasEsf MatiasEsf commented Sep 11, 2021

Captura

my tabnine uses too much cpu, although little ram memory, the extension is great, but it has this little great detail

@asheroto
Copy link

@asheroto asheroto commented Sep 23, 2021

@ET-CS
Copy link

@ET-CS ET-CS commented Sep 26, 2021

Killed my computer :(

image

I have to uninstall until this is resolved

@paulologeh
Copy link

@paulologeh paulologeh commented Dec 9, 2021

i also have the same issue. Using over 1GB of memory on my mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet