gavd.co.uk

Frail and faltering follower of Jesus

Linux command of the day, 9 of 31 - top part 3

By Gavin Davies

I STILL didn’t finish investigating top yesterday, so here’s part 3!

I’m looking briefly at a Linux command every day for a month. I didn’t finish investigating top even in 2 days, so here’s part 3! This isn’t intended to be a tutorial, just some brief notes for fun

Yesterday I finished looking at the ‘header’ section of top‘s output. Today I’ll look through the processes themselves

Each process is listed in a table, which has dozens of columns… How to decipher?! Some are relatively straightforward, but here are a few that I wasn’t sure about and looked up:

  • #th - number of threads runnign in thaat process
  • #wq - work queue total/running
  • ports - mach ports, which are simplex communication channels on the kernel. Mach is the kernel of OSX (now known as MacOS according to macfans, but I’ll probably never update my mental pointer and will call it OSX forever!)
  • PURG - memory pages that can be purged
  • CMPR - compressible memory. I would guess that the OS can compress memory at a cost of CPU cycles, by kinda “defragmenting” it into a contiguous block.
  • state - sleeping or running. It’s quite interesting to see an app sleeping, then interact with it and watch how it briefly goes ‘running’ - my IDE, IDEA, does this and returns to sleeping within second of me switching away from it
  • COW - copy on write faults

Handy command line examples:

  • top -o mem Order by memory - useful for finding memory-munching applications!
  • top -o threads Order by threads - IDEA is using 80 threads as I write this!
  • top -p <pid> top for just single process - useful if there’s something you’re monitoring

Right, I’m thoroughly sick of top now, hopefully look at something new tomorrow!