Skip to the content
FixTheRobot Explore Robotics / UAV / Module 7 / M7-T12

UAV Systems Engineering · Module 7

M7-T12: Compute and memory budgets

A budget is a table of measurements and margins. Without one you discover your limits in flight.

  • Lesson 12 of 19
  • Embedded Systems, Timing and System Integration
  • Established engineering
  • About 5 minutes to read

Onboard compute is finite and shared. A compute and memory budget makes it explicit: what each function needs in each mission mode, what is available, and how much margin remains. It is also the earliest warning that a new feature does not fit.

Learning objectives

After this lesson, you should be able to:

  • Build a per-mode budget of CPU, GPU, memory and bus bandwidth from measurements.
  • Aggregate with the right statistic: sums of means are not sums of worst cases.
  • Set and justify headroom margins.
  • Automate the budget check so that a change that breaks it fails a review.

Conceptual explanation

Established Budgeting practice is standard systems engineering. The numbers in this lesson are placeholders for illustration; every real budget entry must cite a measurement on the target hardware with a stated workload.

A budget has four ingredients:

  • A function list per mission mode (take-off, cruise with mapping, loiter with inspection, degraded navigation, landing). Different modes run different sets; the budget is the maximum over modes, not the average.
  • Resources: CPU (cores, utilisation), GPU, memory (resident set, peak), storage write rate, bus and network bandwidth, power.
  • Measurements: for each function and resource, a distribution, measured on the target hardware under representative load; keep the mean, a high percentile (p95 or p99) and the maximum.
  • Margin policy: the headroom that must remain, based on how bad overrun is (a perception dropout may tolerate 20 %; a hard-real-time loop usually needs 40 % or more) and how uncertain the measurements are.
From function list to budgetList the functions per mission mode, measure each one’s CPU, GPU, memory and bandwidth use on the target, sum per mode, take percentiles and worst cases, and keep a margin. The result is a table that can fail a review.Function listper modeMeasureon target, loadedAggregatesum, peakMarginpercent headroomReviewpass / fail, ownerA budget with no measurements is a wish.
From measurements to a pass/fail table.
Animation of the load of four software functions on a shared processor. The correlation between their bursts is increased from zero to one. For each correlation the histogram of the total load is shown with its 95th percentile and the sum of the four individual 95th percentiles. With independent loads the total p95 is well below the sum; with fully correlated bursts the two coincide. A second panel plots both against the correlation.
Budget on the percentile of the combined load measured together, and add margin for the correlated case. Four illustrative functions with gamma-distributed load, correlated through a shared contention factor; 20000 samples per correlation value. (Looping, about 5 seconds; drawn and computed for this course with illustrative values.)

Engineering intuition

Adding up average CPU use is the classic budgeting error. Averages describe long-run capacity, but the system fails in bursts: when mapping, a detector and a replan all peak together. Peak loads of independent functions rarely coincide, so the sum of maxima is pessimistic and the sum of means optimistic; the truth is measured by running the functions together and taking the high percentile of the combined load.

Memory is the opposite: it is not a time-averaged resource. Resident set grows with map size and queue depths; the peak at the end of the longest mission is what matters, and a leak turns a passing budget into a failure after 40 minutes. Measure memory over a full-length mission, not a 2-minute test.

Mathematical formulation

For nn functions with utilisations uiu_{i} (fraction of the resource) the combined load in a mode is the sum, but for percentile statements the sum of percentiles bounds the percentile of the sum from above. With independent functions of mean μi\mu _{i} and standard deviation σi\sigma _{i}, a Gaussian approximation gives

Combined percentile load (independence assumption)
loadp≈∑iμi+zp∑iσi2\text{load}_p \approx \sum_i \mu_i + z_p\sqrt{\sum_i \sigma_i^{2}}
z95 = 1.645 and z99 = 2.326.

which is less pessimistic than the sum of individual percentiles, and optimistic if loads are positively correlated (they often are: a busy scene raises detector, tracker and mapper load together). Use the measured combined distribution when possible. Headroom is h=1h=1 − loadp_{p}/capacity, required ≥ hmin⁡h_{\min}. For memory, the budget is peak resident set plus allocator overhead plus the OS’s own use, against physical memory minus a safety reserve to avoid swapping.

μi\mu _{i}, σi\sigma _{i}
mean and standard deviation of function i’s load.
zpz_{p}
standard normal quantile for the chosen percentile.
hmin⁡h_{\min}
minimum headroom required.

Architecture and data flow

Profilers and monitors on the target (top/htop, pidstat, tegrastats or nvidia-smi, ros2 topic bandwidth, perf) → recorded time series per process during mission-representative runs → budget script → table of means, percentiles, maxima, headroom per mode → review. The same script runs in continuous integration on recorded profiles so that a change in a function’s cost fails the build before it reaches the vehicle.

Real-world UAV applications

  • Sizing a companion computer for a perception pipeline.
  • Deciding which functions to disable in a degraded mode to keep the estimator on time.
  • Reviewing a new feature’s cost against the remaining headroom.
  • Providing evidence for the compute section of a design review.

Implementation example

This runs as shown. A budget calculator over per-mode measurements (synthetic here, labelled as placeholders): it computes mean, p95 and a Gaussian combined estimate, compares it with a Monte Carlo of correlated loads, and fails when headroom is below the margin.

import numpy as np
rng = np.random.default_rng(12)
# PLACEHOLDER measurements (fraction of a 6-core CPU): replace with measured time series per function on the target
functions = {'vio': (0.55, 0.06), 'detector (cpu part)': (0.30, 0.08), 'mapper': (0.45, 0.10), 'planner': (0.20, 0.12), 'comms+logging': (0.15, 0.03)}
modes = {'cruise-mapping': ['vio', 'detector (cpu part)', 'mapper', 'planner', 'comms+logging'], 'degraded-nav': ['vio', 'planner', 'comms+logging']}
capacity = 6.0; h_min = 0.25; rho = 0.5                                      # required headroom; assumed correlation between functions
def combined(mode, n=200000):
    names = modes[mode]; mu = np.array([functions[k][0] for k in names]); sd = np.array([functions[k][1] for k in names])
    C = rho * np.outer(sd, sd) + (1 - rho) * np.diag(sd ** 2)                 # correlated covariance
    x = rng.multivariate_normal(mu, C, n).clip(min=0).sum(axis=1)             # combined load samples
    gauss = mu.sum() + 1.645 * np.sqrt((sd ** 2).sum())
    return mu.sum(), np.percentile(x, 95), gauss
ok = True
for m in modes:
    mean, p95, gauss = combined(m); head = 1 - p95 / capacity
    print(f"{m:>15}: mean {mean:.2f} cores, p95 (correlated) {p95:.2f}, independent-Gaussian estimate {gauss:.2f}, headroom {head:.0%} -> {'PASS' if head >= h_min else 'FAIL'}")
    ok &= head >= h_min
m, p95, g = combined('cruise-mapping'); assert p95 > g          # correlation makes the independent estimate optimistic
assert ok
A mode budget with a correlated combined load. The measurements are placeholders. Correlation makes the independent estimate optimistic.

Common engineering mistakes

Budget from averages

Failures come from combined peaks; use percentiles of the combined load.

Testing for two minutes

Memory growth and thermal throttling appear over a full mission.

Measuring on a dev machine

Budgets must come from the target in its enclosure.

One budget for all modes

Take the worst mode; check mode transitions too.

No owner or review date

Budgets rot; give each function a budget owner and re-measure on every release.

Failure modes

Failure modes, symptoms and causes
Failure modeHow it shows upLikely cause
Rare overload in flightFrame drops or late estimatorPeaks of correlated loads exceed capacity
Out-of-memory after 40 minutesProcess killedLeak or unbounded map or queue growth
Passing in lab, failing in flightLower throughputThrottling or different load at altitude/lighting
New feature breaks the systemLatency regressionNo budget check in continuous integration

Debugging approach

  1. Plot combined load over time and look at the peaks and what runs at them.
  2. Track resident memory against time over a full mission.
  3. Compare budget predictions with the measured combined load.
  4. Re-measure after every software release.

Practical exercises

  1. Fill in a budget for CPU, GPU and memory for three modes of your own vehicle using measurements.
  2. Change the correlation to 0 and 0.9 and report the p95 and the headroom.
  3. Measure the resident memory of your map over a 30-minute mission.
  4. Write the CI check that fails when headroom falls below 25 %.

Interview questions

Write an answer in your own words, then reveal the model answer. Nothing is sent anywhere.

Question 1

Why not budget from average CPU use?

Model answer

Failures occur when loads peak together; averages hide bursts, and the combined peak depends on correlation, so the combined percentile must be measured.

Question 2

How do you set headroom margins?

Model answer

By the consequence of overrun and the uncertainty of the measurements: hard-real-time functions need larger margins than soft ones, and unmeasured or unrepresentative data needs more.

Question 3

Why measure memory over a full mission?

Model answer

Memory use grows with maps, queues and leaks; the peak at the end of the longest mission is what must fit, which short tests miss.

References and further reading

Primary papers, official documentation and standards. Each claim above that is specific to a tool or version points here.

What’s next

Mark this lesson

Saved in this browser and synced to your account when you are signed in.

Practice this lesson

M7-L5: Calculate compute and power budgets

Fill in a budget table.

Next lesson

M7-T13: Power and thermal budgets

Build a power and thermal budget per mode, including ambient temperature, airflow and throttling behaviour.