5

I'm facing a weird problem that I never had in 4 years using Ubuntu.

Commands in the terminal are running very slowly. A simple clear takes up to 20 seconds, as well as cd, get into vim, everything is really. Sometimes it even freezes the input to the point that I can't type anything for a long time.

I'm currently using Ubuntu 20.04.

I have no idea what could be causing this weird behavior. Can someone shed some light on it?

UPDATE: Htop screenshot

UPDATE 2:

htop screenshot CPU usage high

This shows the CPU usage on its way to 100%, and I found out that this behavior only happens in a specific git repository once I cd in it. I've run git status with some flags and it is using 100% CPU. But the diff is really small. Other git repos in my machine work fine.

joeljpa
  • 137
  • 5
Ian Guimarães
  • 151
  • 1
  • 1
  • 3
  • 1
    I suggest that you use a system monitoring tool like htop to gather information about a possible source of your issue – Nmath Oct 06 '20 at 14:53
  • @Nmath I added a screenshot of htop output. Memory consumption is high, but I'm running an Android emulator, spotify, 10+ tabs in firefox, and development server locally so is expected to be that high. Anyway I still have around 7gb ram left – Ian Guimarães Oct 06 '20 at 15:10
  • The idea is that you keep it up and pay close attention especially when your system comes to a crawl. You're not close to using the limit on your RAM or CPU processes at this snapshot of time. Also, these slow terminal commands, are they happening over a network like when you use SSH? Because you're affected by ping/latency in these situations – Nmath Oct 06 '20 at 16:42
  • Sounds more related to some attached (network) drives that your system waits for. – pLumo Oct 06 '20 at 17:30
  • @Nmath I'm running all these commands on my machine. No ssh connections – Ian Guimarães Oct 06 '20 at 17:51
  • @pLumo can you give an example? Not sure I get it – Ian Guimarães Oct 06 '20 at 17:52
  • @Nmath update de post. I belive that could be git related – Ian Guimarães Oct 06 '20 at 18:30
  • I'd investigate whatever it is that you use git for. AFAIK it shouldn't be active unless you use it and have scheduled some task. – Nmath Oct 06 '20 at 20:56
  • Probably is oh-my-zsh triggering git when I cd in a git folder, so it can show the branch and other information in the status bar – Ian Guimarães Oct 07 '20 at 11:29

2 Answers2

2

I'm facing a weird problem that I never had in 4 years using in Ubuntu.

And more than two years later, I faced the exact same problem :') Same Ubuntu version.

It happened only in one of my project folders for me. htop showed high CPU usage. Every symptom you had checked out with me.

After some experimentation, I found out that in my case clearing my .bash_history fixed it. I further removed some customisation in my .bashrc to prevent it from happening in future.

I had PROMPT_COMMAND="history -a;$PROMPT_COMMAND" in my .bashrc because I wanted my history to instantly update after each run command in my shell (via Is it possible to make writing to .bash_history immediate?). Been using that for years but I removed that line. So my Bash history limit was also set to high and had been collecting everything since then.

I also suspect that duplicate entries were being put in it as well since that's the default. I then added the ignoredups in my rc file to disable duplicate entries. I'm assuming that large history + the .bashrc customisation didn't go well with my Git repo.

Numerous factors are probably at work here. I can only speculate what caused this weird behaviour being a novice but what I can confirm is that this solved my problem. I hope that offhand chance this fix can help someone else.

joeljpa
  • 137
  • 5
0

I had this problem and I tried many solutions available on the internet but nothing worked. but upgrating packages has solved problem quickly.

  1. sudo apt update
  2. sudo apt upgrade
  3. restart the terminal.

Thank you.