Intermittent lag in command terminal?

I have a workstation that we run numerical simulations on using in-house code, submitting jobs from the command line and using vim to edit/view files. My problem is that whenever we are running at least one job (not even up to full capacity of CPUs available), we see intermittent lag in the command line while there is no lag in the gnome desktop. The command line will seize up. Most notably when using vim to save files it will almost always take 10-30 seconds to save even the simplest one line files. Has anyone faced a similar problem or have any ideas? We are using kernel 6.2.0-26-generic and ubuntu 22.04.4 LTS

Thanks

Asked By: STL

||

welcome to the forum.

System Resources

This seems like a hunt to find which system resource is insufficient but we can’t tell because there is not enough information. You could provide details like:

df -h
uptime
iostat -d -k -x 1 1 | awk '/^sda/ {print $NF"%"}'
sudo dmesg | tail

However, I think it would be better to look through the system logs yourself and provide one or a few happening when the issue occurs.

Separate the Tasks

One easy win I can see is to just separate your scripts from vim file editing.

  • Log into a separate computer (could be a very simple Ubuntu instance on a Raspberry Pi Zero or a VM)
  • SSH into the Ubuntu system in question
  • Edit files with vim

This will only require the Ubuntu system in question to save changes to the file versus an interactive session.

Best Solution

This is really what Docker is great for. You limit system resources being accessed while gaining insight into what the task is requiring for resources. "Numerical simulations" and "in-house code" sound like a great use case for the versioning functionality as well.

USB Bus

Using Time Machine backups from a USB flash drive causes my keyboard/mouse to lag. When it happens, I can use my bluetooth, directly connected track pad just fine. Breaking up tasks would help identify a problem with the USB bus.

Session Logging

This is probably overkill but you could record the terminal session and review the log to see what’s happening. Here’s how:

  1. From Terminal

    script session.log

Replace session.log with the filename you want to save the log as. This will start recording your terminal session to the specified file.

  1. Reproduce the actions that are causing the lag in the terminal.
  2. When finished type exit to stop recording the session.
  3. View the log file.
  4. Look for any commands/actions that might be causing the lag, or errors/output that might indicate the cause.

Note: this includes any commands you enter, their output, and any error messages. The file can get large quick.

Answered By: musicman1979