At first, the question seems to be a little bit silly/confusing as the OS does the job of managing process execution.
However, I want to measure how much some processes are CPU/IO-bound and I feel like my OS is interfering on my experiments with, for instance, scheduled OS processes.
Take as an example the following situation:
I ran the process A twice and got the following output from the tool "time" (time columns in seconds):
+---+-------+---------+-----------+---------+
|Run|Process|User Time|System Time|Wall time|
+---+-------+---------+-----------+---------+
|1 |A |196.3 |5.12 |148.86 |
|2 |A |190.79 |4.93 |475.46 |
+---+-------+---------+-----------+---------+
As we can see, although the user and sys time are similar, the elapsed time of both drastically changes (diff. of ~5 min). Feels like something in my environment caused some sort of contention.
I want to stop every possible background process/services to avoid any kind of noise during my experiments but I consider myself a novice/intermediate unix-user and I don't know how to guarantee this.
I'm using Linux 4.4.0-45-generic with Ubuntu 14.04 LTS 64 bit.
I really appreciate the assistance. If you guys need any missing information, I will promptly edit my post.
CPU Info
$ grep proc /proc/cpuinfo | wc -l
8
$ lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
NUMA node(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 60
Stepping: 3
CPU MHz: 4002.609
BogoMIPS: 7183.60
Virtualization: VT-x
L1d cache: 32K
L1i cache: 32K
L2 cache: 256K
L3 cache: 8192K
NUMA node0 CPU(s): 0-7
Best Answer
You have a kernel option configuration where a CPU won't be used by the OS, it is called
isolcpus
.This configuration I am about to describe how to setup, can have far more uses than for testing.
Meru for instance, uses this technology in their Linux-based AP controllers, to keep the network traffic from interfering with the inner workings of the OS, namely I/O operations.
I also use it in a very busy web frontend, for quite the same reasons: I have found out from life experience that I lost control too regularly for my taste of that server ; had to reboot it forcefully until I separated the front end daemon on it´s own dedicated CPUs.
As you have 8 CPUs, that you can check with the output of the command:
or
Add in Debian/Ubuntu in the file
/etc/default/grub
to the optionGRUB_CMDLINE_LINUX
:(it is 7, because it starts in 0, and you have 8 cores)
Then run,
This is telling the kernel to not use one of your cores.
Reboot the system.
Then start your process.
Immediately after starting it, you can change for the 8th CPU (7 because 0 is the 1st), and be quite sure you are the only one using that CPU.
For that, use the command:
For reading more about it, see: isolcpus, numactl and taskset
Also using
ps -eF
you should see in the PSR column the processor being used.I have a server with CPU 2 and 3 isolated, and indeed, it can be seen with
ps -e
the only process in userland as intended, ispound
.If you compare it with the non-isolated CPUs, they are running many more things (the window below slides):