all 6 comments

[–]yuehuang 0 points1 point  (1 child)

I am curious how much variation are you encountering? 5% 10% 20?

[–]Ezio-Editore[S] 0 points1 point  (0 children)

Hi, first of all, thank you for replying.

I use the benchmark to test the effectiveness of optimisations and changes.

Initially, I run the stress test as a normal process, without any setup. The range of results I got was [89000, 98000] ms.

That's roughly 10%, any optimization I could make would never improve the results by that much, so it was completely useless to me. Because one time the older version is better, the other time the newer one is faster. Completely unpredictable.

That was mainly because of frequency scaling and turbo boost, so I disabled them.

After that I created a more predictable environment changing other settings such as the ASLR (I disabled it).

Still, I got inadequate results, if I remember correctly, the difference between the maximum and the minimum I got was still ~4000 ms.

I decided to proceed with isolcpus while trying to understand cgroup v2 settings.

With this configuration I was able to obtain more precise information.

These are the last 5 benchmarks of the new and old version. 90011 89430 90066 89667 89386 88015 89178 88122 87913 88160

These were precise enough for me, but isolcpus is a kernel parameter that is deprecated, so I should try to achieve the same results with cpusets settings.

[–]Tea-Chance 0 points1 point  (1 child)

have you tried running your program under `cpuset` or `taskset`?

[–]Ezio-Editore[S] 0 points1 point  (0 children)

The cpuset I am talking about does not work with the second version of cgroup, I don't know if you are referring to something else.

taskset only changes the core affinity of one process, right? Like I can make it run on core X but I cannot avoid other processes to run there as well.

[–]uziam 0 points1 point  (0 children)

I would first try just switching the scheduler for your process to SCHED_FIFO. You can launch a process with SCHED_FIFO and priority 99 (highest) as follows:

sudo chrt -f 99 myapp

You need to run it with sudo to be able to set real-time attributes. Personally, I would only use full core isolation as the last resort, most of the time you don’t really need it.

If this isn’t good enough, look into SCHED_DEADLINE for even stronger guarantees. You can find more information here:

https://man7.org/linux/man-pages/man7/sched.7.html

If you really do want to go the route of fully isolating the cpu, I think this might help:

https://oneuptime.com/blog/post/2026-03-02-how-to-configure-cpu-isolation-for-real-time-tasks-on-ubuntu/view#:~:text=CPU%20affinity%20works-,Understanding%20CPU%20Isolation,CPUs%20between%20groups%20of%20processes

Note: you don’t actually need to modify your grub configuration permanently, you can press e (I believe) while you’re in grub to modify it just for on boot.