SPB Git

Repository Public License

performance.md 4.9 KB

# Performance

# What has been measured

Only two things, both on the development Mac (Apple M5 Max, 48 GB, macOS 27.0, release build):

  1. the imaging engines, with orix-bench;
  2. the peak memory of bracket fusion, with /usr/bin/time -l.

Nothing has been measured on an iPhone or iPad. A Mac's CPU, GPU and memory are not an iPhone's; treat the figures below as proof that the algorithms are cheap relative to a frame interval, not as iPhone numbers.

# Engines

cd Packages/ORIXCameraKit && swift run -c release orix-bench. Medians. Source: benchmarks/.

Operation 1080p 4K
Histogram (RGB + luma, every pixel) 0.98 ms 2.90 ms
Focus analysis (480 px luma plane) 0.73 ms 1.74 ms
Monitor pass: peaking + zebra + LUT, GPU, including readback 3.39 ms 12.26 ms
Accumulate one frame (long exposure) 1.24 ms 4.98 ms
Accumulation preview (float → 8-bit) 4.21 ms 16.41 ms
Night stack: merge one frame 4.96 ms 22.09 ms
Night stack: register one frame (Vision) 2.35 ms 5.49 ms
Operation Input Result
Bracket fusion 3 MP × 3 130 ms
Bracket fusion 12 MP × 3 488 ms
Edit recipe render, preview 1600 px 12 MP 15 ms
Edit recipe render, full size 12 MP 18 ms
Export JPEG / HEIC / TIFF / PNG 12 MP 23 / 58 / 146 / 241 ms
Encode H.264 / HEVC / ProRes 422 1080p, 120 frames 153 / 143 / 901 fps

Notes: the monitor figure includes reading the texture back to memory, which the live monitor never does. The "resident memory after" lines of the benchmark file are a coarse in-process reading; the fusion memory figures to use are the ones below.

# Bracket fusion memory

/usr/bin/time -l .build/release/orix-bench fusion <megapixels>, three exposures, maximum resident set size:

Size Peak Baseline (images only)
6 MP 542 MB 62 MB
8 MP 720 MB 78 MB
12 MP 929 MB 109 MB

Roughly 75–90 MB per megapixel. Consequence in the app (CameraModel.fusionPixelBudget):

Physical memory Fusion working size
under 5 GB 4 MP
under 7 GB 6 MP
under 11 GB 8 MP
11 GB or more 12.5 MP

Whether these tiers are right for iOS's per-app memory limits has to be confirmed on devices.

# Simulator

Analysis mode reports delivered frame rate, jitter and analysis time live. In the Simulator these describe the Mac running a timer-driven test scene and are not recorded here.

# To measure on a device

Metric Method
Cold launch to first frame Xcode Organizer launch metrics; add signposts around CameraModel.start and the first receive(_:)
Time to first preview after a mode or lens change signposts around reconfigure
Shutter latency signpost from shutter() to didFinishProcessingPhoto; compare .quality and .speed
Capture-to-save signpost from the delegate callback to finishIndexing
RAW development time time RAWDeveloper.develop + render on real DNGs, 12 and 48 MP
Video frame drops the recorder's drop count and the capture drop count over ten minutes at each format and codec
Histogram and peaking latency Analysis mode: "Analysis time per frame"; Metal frame time in Instruments
Memory Instruments (Allocations, VM Tracker) in each mode; fusion and night stack peaks
Thermal systemPressureState over a long 4K recording; time to "serious"
Battery Instruments energy log over fifteen minutes of preview and of recording

Signposts are not in the code yet.

# Design choices that bound the cost

Choice Effect
One Metal pass draws the picture and all aids one GPU pass per display refresh, no CPU image work for overlays
Analysis on a utility queue with a busy flag, at most 12 Hz analysis can never back up the capture queue
Focus score on a 480-pixel luma plane constant cost whatever the stream size
Late video frames discarded by the data output the pipeline never accumulates latency
Accumulators convert row by row into a scratch buffer working memory is three float planes, nothing more
Fusion keeps sources as 8-bit and builds float planes one at a time lower peak than holding every exposure in float
Edit previews are downsized before filtering interactive sliders on 12 MP+ sources
Monitor at 30 Hz under serious thermal pressure less GPU load when it matters
Thumbnails rendered off the main thread and cached smooth library scrolling

# Known costs not yet quantified on a device

  • BGRA conversion of the video stream at 4K60.
  • Vision registration plus merge of a 4K frame (about 28 ms on the Mac) exceeds a 30 fps frame interval on slower hardware; the night stack tolerates this because the data output discards late frames, but the burst will span more time.
  • ProRes 422 write throughput to internal storage at 4K.
Files main
Menu

Theme