4

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

Commands in terminal are running very slow. A simple clear take 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 a light on it?

UPDATE: Htop screenshot

UPDATE 2: In this screenshot shows the cpu usage on its way to 100%, and I found out that this behavior only happens in a specific git repository which once I cd in it, the git command status is ran with some flags and it is using 100% CPU. But the diff is really small. Other git repos in my machine works fine

muru
  • 193,181
  • 53
  • 473
  • 722
Ian Guimarães
  • 141
  • 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

1

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 :') I'm on Ubuntu 20.04. Happens only in one of my project folders and htop shows cpu being used. Every symptom you had checks out.

I'd assume there could be numerous factors that could cause this. Still, I hope that off-hand chance this fix that helped me can help someone else.

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

Let me elaborate.

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. Been using that for years (this question). I removed this line. My bash history limit was set to high and had been collecting for over a year.

I also suspect that duplicate entries were being put in it as well since that's the default. Can't confirm this though since by then I already cleared my old history. I'm assuming that large history + the .bashrc customisation didn't go well with my repo. I then added the 'ignoredups' in my rc file to prevent this from happening in future.

I can only speculate here on what caused this weird behaviour being a novice but what I can confirm is that this solved my problem.

joeljpa
  • 125
  • 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.