Conceptio › Archive › arXiv CS
arXiv CS open access

Benchmarking Linux CGroup and Schedule Idle

Anna Arpaci-Dusseau · arxiv_cs
arXiv CS · Papers
Open Source ↗Direct PDF ↓
kerneloperating-systemsvirtualization
cgroups are a Linux kernel primitive that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O) of a collection of processes. Many provider-side serverless systems (Mitosis, gVisor, Havest VM, FAASM) leverage linux containers based around cgroups/namespaces for their performa
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

Benchmarking Linux CGroup and Schedule Idle

arXiv:2611.23655v1 [cs.OS] 18 Nov 2026

Anna Arpaci-Dusseau December 2023

1

Introduction

cgroups are a Linux kernel primitive that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O) of a collection of processes. Many provider-side serverless systems (Mitosis [10], gVisor [1], Havest VM [11], FAASM [8]) leverage linux containers based around cgroups/namespaces for their performance isolation. However, how well does this primitive map to the needs of serverless platforms? How does the linux CFS scheduler deal with cgroups and SCHED IDLE and what are the core sources of high tail latency? Would a new primitive design fit the needs of serverless isolation better? A first step in answering these questions is to identify the current behavior of cgroups and a sched idle policy via a thorough benchmarking study. We emulate the setting of latency-critical (LC) server in the presence of an intensive background (BE) process and note the impact of each primitive on the performance of the server. We show it is non-trivial to balance the potential tail-latency impact on a LC server with the throughput of BE tasks. Futhermore, there are many variables to adjust for the developer between hard maximum bandwidth limits, weighted cpu shares, the presence of the sched idle policy, or additionally ”niceness” priority in the scheduling policy. There has been some work exploring changes to CFS and cgroups to improve serverless performance [4], but little in the space of how this would interact with the sched idle policy or different priority tasks. The complete code for the cgroup-benchmark suite is available at: https://github.com/AnnaAD/cgroup-benchmark.

2

Background

2.1

Cgroups and CFS

cpu.weight controls the proportional distribution of cpu time for each cgroup. [6] For example: echo "150" > /sys/fs/cgroup/Example/g1/cpu.weight echo "100" > /sys/fs/cgroup/Example/g2/cpu.weight 1

echo "50" > /sys/fs/cgroup/Example/g3/cpu.weight This command set the weights of the children cgroups (g1, g2, g3). These weights are then summed up to a total cpu weight. The CPU resource is then distributed proportionally based on the that group’s individual weight compared to the sum of all weights. As a result, when all processes run at the same time, the kernel allocates to each of them the proportionate CPU time based on their respective cgroup’s cpu.weight. cpu.max sets the maximum bandwidth for all processes within a cgroup. [6] For example: echo "200000 1000000" > /sys/fs/cgroup/Example/tasks/cpu.max. The first value is the allowed time quota in microseconds for which all processes collectively in a child group can run during one period. The second value specifies the length of the period. During a single period, when processes in a control group collectively exhaust the time specified by this quota, they are throttled for the remainder of the period and not allowed to run until the next period.

2.2

SCHED IDLE

The CFS (completely fair scheduling) class hosts most of the user tasks; it implements three scheduling policies: SCHED NORMAL, SCHED BATCH, and SCHED IDLE. [5], [7] A task under any of these policies gets a chance to run only if no other tasks are enqueued in the deadline or realtime classes (though by default the scheduler reserves 5% of the CPU for CFS tasks regardless). The scheduler tracks the virtual runtime (vruntime) for all tasks, runnable and blocked. The lower a task’s vruntime, the more deserving the task is for time on the processor. CFS accordingly moves low-vruntime tasks toward the front of the scheduling queue. The priority of a task is calculated by adding 120 to its nice value, which ranges from -20 to +19. The priority of the task is used to set the weight of the task, which in turn affects the vruntime of the task; the lower the nice value, the higher the priority. The task’s weight will thus be higher, and its vruntime will increase more slowly as the task runs. In Linux kernel version 5.4, the CFS scheduler behavior was modified to favor running new SCHED NORMAL tasks on a warm SCHED IDLE cpu, fixing previous bug in SCHED IDLE which would have an idle task running on a single CPU for prolonged periods of time [5]

3

cgroup-benchmark suite

The aim of cgroup-benchmark suite is to simulate a LC server with a memory intensive BE background task. We select Matrix Multiplication as our memory intensive task, and implement our multi-threaded TCP server in C++ with the <threads> library.

2

• BE Matrix Multiplication: matmul.py <nrows> <ncols> - multiplies two nrows × ncols dimension matrices together using numpy. Numpy implements a multithreaded matrix multiplication function. • LC Server multi tcp server/server <mm?> <ncols> <nrows> - a multithreaded TCP server which creates a new thread per client. If mm = TRUE, then on recieving a client request the server performs a single matrix multiplication of two nrows × ncols dimension matrices before responding. If mm = FALSE, the server responds right away. • LC Server Client - a simple process which repetedly pings the server and records the obeserved RTT of each ping.

3.1

Attempted Configurations

• Scenario 1: Light Server Load – Server has no workload, responds immediately to any client requests. – Baseline: Start LC server and 16 clients. BE process of 500x500 matrix multiplication begins after 30 seconds. – cgroup-weight: Start LC server and 16 clients in cgroup server. BE process of 500x500 matrix multiplication in cgroup background begins after 30 seconds. cgroups are weighted server:background, 2048:1024. – cgroup-max: Start LC server and 16 clients in cgroup server. BE process of 500x500 matrix multiplication in cgroup background begins after 30 seconds. cgroup server is configured to have no maximum bandwidth, while background has a maximum of 50% CPU bandwidth. – cgroup-sched idle-weight: Start LC server and 16 clients in cgroup server. BE process of 500x500 matrix multiplication in cgroup background with SCHED IDLE policy begins after 30 seconds. – cgroup-sched idle-max: Start LC server and 16 clients in cgroup server. BE process of 500x500 matrix multiplication in cgroup background with SCHED IDLE policy begins after 30 seconds. cgroups are weighted server:background, 2048:1024. – sched idle: Start LC server and 16 clients. BE process of 500x500 matrix multiplication begins after 30 seconds with SCHED IDLE policy. cgroup server is configured to have no maximum bandwidth, while background has a maximum of 50% CPU bandwidth. • Scenario 2: Heavy Server Load – Server has heavy workload, performs a 500x500 malloced matrix multiplication upon receiving a client request. – Baseline – cgroup-weight 3

– cgroup-max – cgroup-sched idle-weight – cgroup-sched idle-max – sched idle • Scenario 3: Reasonable Server Load – Server has reasonable workload, performs a 100x100 matrix multiplication upon receiving a client request. – Baseline – cgroup-weight – cgroup-max – cgroup-sched idle-weight – cgroup-sched idle-max – sched idle

4

Evaluation Results

The experiments were run on Cloudlab 2-node LAN experiment configuration. Each node has 16 cores. Linux Kernel Version: 5.15.0-86-generic (which uses the CFS scheduler). The below tests use cpu.weight as the means to distribute cpu time between the server and background tasks. However, tests were run with cpu.max, though cpu.weight seems to show the trends better. There are 16 clients, that the number of client is proportional to the number of cores and there are not many more cores than clients, or many fewer (which would trivially result in completely unused cores for BE processes).

4.1

Reasonable Server Load

The most clear, promising results, came from the reasonable server load.

4

latency (ns) 73563070 82408201 88914093 With BE Task P50: 59819570 P99: 107413252 P99.99: 135954554 P50: P99: P99.99:

-18% +30% +50%

Figure 1: Reasonable Server Load - Baseline. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

latency (ns) 74577791 83403921 91537968 With BE Task P50: 71003110 P99: 105574298 P99.99: 119188803 P50: P99: P99.99:

-4% +15% +30%

Figure 2: Reasonable Server Load - cgroup (cpu.weight) The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

We see a small (12%) decrease in 99.9% tail latency with cgroups in this setting (with cpu.weight). Overall, with cgroups turned on, we see more stable results and a smaller effect on tail latencies when starting the BE task, with an average decrease of 20% in the difference between tail latencies with cgroups.

5

latency (ns) 73738949 83778371 92482737 With BE Task P50: 66796023 P99: 93924664 P99.99: 152616914 P50: P99: P99.99:

-9% 12% +65%

Figure 3: Reasonable Server Load - cgroup (cpu.weight) and idle. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

With Sched idle and cgroups we see slight improvement to the p99 tail latency, and it seems to change the characterisitic of the reported latencies to occur over smaller range overall. However, the p99 only improves by ≈5% from without sched idle.

latency (ns) 73862825 82168891 103361643 With BE Task P50: 71185558 P99: 82244143 P99.99: 107807689 P50: P99: P99.99:

-3% +0.1% +0.4%

Figure 4: Reasonable Server Load - Idle. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

Using only a SCHED IDLE policy proved to maintain the tail latency of the server the most consistent, at the cost of decreasing the throughput of BE matrix multiplication by 7.5x.

4.2

Light Server Load

One possible limitation of a heavier server load is that spikes in tail latencies are less noticable overall due to a higher baseline RTT. If the work of 6

the server before responding is much higher than any kernel overhead due to cgroups/sched idle we might not identify a millisecond-level increase. One limitation of a very light server load is there seems to be performance benefits from starting a BE task, as it potentially warms and stabilizes the CPU frequency. For all these experiements, the CPU Frequency of all cores was set to the maximum (2000 mHz), however, even with this mitigation, we see that starting real work on the CPU improves performance of the LC server.

latency (ns) P50: 218037 P99: 589715 P99.99: 978404 With BE Task P50: 117088 P99: 250568 P99.99: 1228421

Figure 5: Light Server Load Baseline. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

latency (ns) P50: 216684 P99: 592284 P99.99: 1021502 With BE Task P50: 205964 P99: 580310 P99.99: 2785662

Figure 6: Light Server Load cgroup (cpu.weight). The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

7

latency (ns) P50: 217550 P99: 582401 P99.99: 1025065 With BE Task P50: 118966 P99: 275199 P99.99: 650053

Figure 7: Light Server Load cgroups (cpu.weight) and sched idle. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

With sched idle we see a complete elimination of these most extreme tail latency spikes that occur only when the BE task is present.

4.3

Heavy Server Load

The extremely heavy serverload eliminated the problem of speed-ups with BE tasks being stated, however accute spikes in tail latency were hard to detect due to a larger overall granularity in RTTs.

latency (ns) P50: 2397824243 P99: 4006877900 P99.99: 4021320829 With BE Task P50: 4503614119 P99: 5241836059 P99.99: 5437727897

Figure 8: Heavy Server Load Baseline. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

8

latency (ns) P50: 2397824243 P99: 4426738779 P99.99: 4431107022 With BE Task P50: 3788543978 P99: 4116269462 P99.99: 4129458508

Figure 9: Heavy Server Load with cgroups (cpu.weight). The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

latency (ns) P50: 2617646084 P99: 4431118506 P99.99: 4433799972 With BE Task P50: 3458744314 P99: 4200929889 P99.99: 4250282000

Figure 10: Light Server Load with cgroups and sched idle. The blue lines indicate the latency of the 16 clients, the orange line indicates the latency of matrix multiplication for the BE task.

Even when the tail latencies are at the coarser-grained scale, we can still see a slight improvement with sched idle policy. There was a 57% in p50 latency with/without BE task with no idle policy, whereas there was only a 32% increase with/without BE task with idle.

4.4

Conclusion

Early experimentation with cgroup benchmark suites indicates that sched idle policy is critical in reducing one-off tail latency spikes. One theory of why sched idle reduces these spikes is because it leads to greater affinity of server processes to a set of cores, and reduced task migration. This would lead to fewer instances where a packet for a task arrives on a different core which can cost

9

CPU time [3]. However, further work is needed to complete the explanation of these tail latency spikes.

4.5

Future Work

Closer tracing of what is causing the tail latency spikes is necessary to complete the story of cgroups and sched idle in the serverless settings. Using kernel tracing tools, like trace cmd visualized with KernelShark[9] for scheduler behavior or a flame graph of the kernel call stacks [2] could be promising. Furthermore, it may be useful to pin certain tasks to certain CPUs so the effect of scheduling across CPU cores vs the usage within one CPU core can be identified. Additionally, dynamically varying the number of clients, as opposed to the static-state testing, will be critical in understanding all the effects of these kernel primitives.

References [1]

Anjali, Tyler Caraza-Harter, and Michael M. Swift. “Blending Containers and Virtual Machines: A Study of Firecracker and GVisor”. In: Proceedings of the 16th ACM SIGPLAN/SIGOPS International Conference on Virtual Execution Environments. VEE ’20. Lausanne, Switzerland: Association for Computing Machinery, 2020, pp. 101–113. isbn: 9781450375542. doi: 10 . 1145 / 3381052 . 3381315. url: https : / / doi . org / 10 . 1145 / 3381052.3381315.

[2]

“Blazing Performance with Flame Graphs”. In: Washington, D.C.: USENIX Association, Nov. 2013.

[3]

Yimin Du et al. “A Survey on Mechanisms for Fast Network Packet Processing”. In: Proceedings of the 2023 4th International Conference on Computing, Networks and Internet of Things. CNIOT ’23. , Xiamen, China, Association for Computing Machinery, 2023, pp. 57–66. isbn: 9798400700705. doi: 10 . 1145 / 3603781 . 3603792. url: https : / / doi . org / 10 . 1145 / 3603781.3603792.

[4]

Al Amjad Tawfiq Isstaif and Richard Mortier. “Towards Latency-Aware Linux Scheduling for Serverless Workloads”. In: Proceedings of the 1st Workshop on SErverless Systems, Applications and MEthodologies. SESAME ’23. Rome, Italy: Association for Computing Machinery, 2023, pp. 19–26. isbn: 9798400701856. doi: 10 . 1145 / 3592533 . 3592807. url: https : //doi.org/10.1145/3592533.3592807.

[5]

LWN.net. Fixing SCHED IDLE. 2019. url: https://lwn.net/Articles/ 805317/.

10

[6]

Inc. Red Hat. Chapter 24. Using cgroups-v2 to control distribution of CPU time for applications. 2023. url: https://access.redhat.com/ documentation/en-us/red_hat_enterprise_linux/8/html/managing_ monitoring _ and _ updating _ the _ kernel / using - cgroups - v2 - to control-distribution-of-cpu-time-for-applications_managingmonitoring-and-updating-the-kernel#proc_controlling-distributionof - cpu - time - for - applications - by - adjusting - cpu - bandwidth _ using- cgroups- v2- to- control- distribution- of- cpu- time- forapplications.

[7]

Inc. Red Hat. Chapter 32. Tuning scheduling policy. 2023. url: https: //access.redhat.com/documentation/en-us/red_hat_enterprise_ linux / 8 / html / monitoring _ and _ managing _ system _ status _ and _ performance/tuning-scheduling-policy_monitoring-and-managingsystem-status-and-performance.

[8]

Simon Shillaker and Peter Pietzuch. “Faasm: Lightweight Isolation for Efficient Stateful Serverless Computing”. In: 2020 USENIX Annual Technical Conference (USENIX ATC 20). USENIX Association, July 2020, pp. 419–433. isbn: 978-1-939133-14-4. url: https://www.usenix.org/ conference/atc20/presentation/shillaker.

[9]

Using KernelShark to analyze the real-time scheduler. url: https://lwn. net/Articles/425583/.

[10]

Xingda Wei et al. “No Provisioned Concurrency: Fast RDMA-codesigned Remote Fork for Serverless Computing”. In: 17th USENIX Symposium on Operating Systems Design and Implementation (OSDI 23). Boston, MA: USENIX Association, July 2023, pp. 497–517. isbn: 978-1-939133-34-2. url: https://www.usenix.org/conference/osdi23/presentation/ wei-rdma.

[11]

Yanqi Zhang et al. “Faster and Cheaper Serverless Computing on Harvested Resources”. In: Proceedings of the ACM SIGOPS 28th Symposium on Operating Systems Principles. SOSP ’21. Virtual Event, Germany: Association for Computing Machinery, 2021, pp. 724–739. isbn: 9781450387095. doi: 10.1145/3477132.3483580. url: https://doi. org/10.1145/3477132.3483580.

11

Related documents

Record · ID 1702543 · SHA-256 4b0828ce3aef9c67
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive