UW-Madison Biochemistry Resource Wrapper - Comprehensive Guide

The UW-Madison Biochemistry Resource Wrapper is a Bash script designed to manage system resources while executing standalone programs. It helps users control CPU and memory usage, ensuring efficient task execution without overloading the system. This guide provides explanations of essential concepts, including CPU cores and their role in processing, how CPU percentage limits affect performance, the function of NUMA in memory allocation, and how the script applies resource constraints to optimize computing tasks.

Command-line Options

Command Options

Option

Description

Example Usage

-p <CPU percentage> Limits CPU usage to a percentage. control -p 50 -m 4G -- test.py arg1 arg2
-C <CPU cores> Forces execution on specific CPU cores. control -C 0-3 -m 4G -- test.py arg1 arg2
-m <Memory> Defines memory allocation limits. control -m 2G -- test.py arg1 arg2
-n <NUMA node|auto> Binds process to a NUMA node. control -n auto -m 4G -- test.py arg1 arg2
-s <script> Specifies the script to be executed. control -C 0-3 -n auto -m 4G -s test.py
-s <script> -- <script arguments> Ensures script arguments are passed correctly. control -C 0-3 -n auto -m 4G -s test.py -- --mice 2 --rats 2

CPU Percentage (-p) vs. Core Binding (-C)

The script provides two distinct ways to control how CPU resources are allocated:

  1. Limiting CPU usage by percentage (-p)
  2. Binding execution to specific cores (-C)

Each method affects performance differently, depending on workload demands and system architecture.

What is CPU Percentage Limiting (-p)?

The -p flag sets an upper limit on how much CPU time a process can use. Instead of restricting execution to specific cores, the process can run on any available CPU core, but its total CPU consumption is throttled.

Example Usage

control -p 50 -m 4G -s test.py

  • Limits CPU usage to 50% of total available processing power.
  • The process can run on any core, but the scheduler ensures it never exceeds 50% utilization across all cores.

Performance Impact

Best for shared computing environments where multiple processes need fair CPU access.

Prevents system slowdown by avoiding excessive CPU usage.

Not ideal for high-performance computing tasks that require dedicated cores.

Cannot be used with NUMA binding (-n) since it applies across all cores globally.

What is Core Binding (-C)?

The -C flag restricts execution to specific CPU cores, ensuring the process does not migrate between cores.

Example Usage

control -C 0-3 -m 4G -s test.py

  • The process only runs on cores 0, 1, 2, and 3.
  • Unlike -p, it can fully utilize these cores if needed.

Performance Impact

Best for high-performance computing tasks, ensuring dedicated CPU resources.

Works well with NUMA binding (-n) for memory locality optimization.

Can cause CPU congestion if too many tasks are assigned to the same cores.

Comparison: When to Use Each?

Comparison table
Feature -p (CPU Percentage) -C (Core Binding)
Limits CPU usage ✔ Yes ✘ No (full utilization allowed)
Assigns process to specific cores ✘ No ✔ Yes
Prevents system slowdown ✔ Yes ✘ No (depends on core availability)
Best for shared workloads ✔ Yes ✘ No
Best for dedicated workloads ✘ No ✔ Yes
Can be used with NUMA binding (-n) ✘ No ✔ Yes

Scenario-Based Recommendations

If I want to ensure my process doesn’t use too much CPU, but still runs smoothly, what should I use?

Use -p, since it prevents excessive CPU usage while allowing execution across available cores.

control -p 50 -m 4G -s test.py

If I want to dedicate specific cores to my process for better performance, what should I use?

Use -C, ensuring the process runs exclusively on assigned cores for maximum efficiency.

control -C 0-3 -m 4G -s test.py

If I need the best possible performance and memory locality, how should I configure my execution?

Use -C together with -n auto, optimizing both CPU and memory placement.

control -C 0-3 -n auto -m 4G -s test.py

What is NUMA (-n)?

NUMA (Non-Uniform Memory Access) is a system architecture that divides memory into different regions, each attached to specific CPU nodes. Memory access times vary depending on whether the process is using local memory (fast) or remote memory (slower).

When to Use NUMA Binding

If a program benefits from low-latency memory access, binding it to a specific NUMA node can improve performance.

Understanding Parameter Formatting (-- Before Script Name)

When executing a script using the wrapper, all resource control options must come before the script name, and -- should be used as a separator to ensure proper argument handling.

Why is -- Required?

In command-line execution, -- is a special separator that prevents the wrapper from misinterpreting arguments meant for the script itself.

Example of Correct Usage

control -p 50 -m 4G -s test.py -- input.txt -verbose

  • control: The resource wrapper being executed.
  • -p 50: Limits CPU usage to 50%.
  • -m 4G: Allocates 4GB of memory.
  • --: Separator preventing confusion between wrapper options and script arguments.

What Happens Without --?

If -- is omitted, the wrapper might misinterpret arguments as its own, causing execution errors. Always use -- when passing additional arguments to a script.

Common Scenarios & Recommended Commands

If I want to limit CPU usage to 40% and use 3GB of memory:

control -p 40 -m 3G -s test.py

If I want to restrict execution to cores 1-3 and allocate 2GB of memory:

control -C 1-3 -m 2G -s test.py

If I want to run a process on a NUMA node automatically selected by available free memory:

control -n auto -m 4G -s test.py

If I need NUMA binding and core selection together (using cores 0-3 with automatic NUMA node selection):

control -C 0-3 -n auto -m 4G -s test.py

Important Notes

  • -s must always come last, ensuring that the script receives its intended arguments properly.
  • Scripts do not need to be executable; the wrapper determines the appropriate execution method.
  • CPU percentage (-p) cannot be combined with NUMA binding (-n), since -p applies globally across all cores.


Keywords:
script bash wrapper compute computation throughput
Doc ID:
150234
Owned by:
Jeremy H. in CALS Biochemistry IT
Created:
2025-04-30
Updated:
2025-05-07
Sites:
CALS Biochemistry Information Technology, CALS Information Technology