# Performance

What a frame, a load and an avatar cost, as `sona-bench` measures them, and the settings that move each number.
Every figure on this page is `sona-bench`'s own output, as it printed it. The scene is the hard case: every avatar in its own random outfit and body from the full catalogue (`--outfits random`), at
1920 x 1080, the median of three runs.

## Frame time

| Scene, machine | ms a frame (CPU, GPU) | Draws a frame |
|---|---|---|
| 1,000 different avatars: Intel Arc iGPU (Core Ultra 9 185H), Vulkan | 14.05 (3.38, 13.98) | 9,470 |
| 1,000 different avatars: RTX 4000 Ada machine, Vulkan | 1.79 (1.77, 1.59) | 9,470 |
| 10,000 different avatars, stadium, LOD on: Intel Arc iGPU (Core Ultra 9 185H), Vulkan | 11.46 (7.84, 11.37) | 5,831 |
| 10,000 different avatars, stadium, LOD on: RTX 4000 Ada machine, Vulkan | 7.56 (7.5, 2.87) | 5,831 |

With LOD on, far avatars are drawn as sprites from atlas pages, which is why the stadium takes fewer draws than the
grid of 1,000.

## Load time

| What | Machine | Value |
|---|---|---|
| 1,000 different avatars, all ready after (ms) | Intel Arc iGPU | 2,422 |
| 10,000 different avatars, all ready after (ms) | Intel Arc iGPU | 14,939 |
| One avatar ready, items already in memory, median (ms) | Intel Arc iGPU | 25.77 |
| One avatar ready, items read from disk, median (ms) | Intel Arc iGPU | 26.11 |

Avatars load on worker threads and are committed inside `sona_update`, a few per frame, so a load does not stall
the frame. From the gate the first load also waits on the network; what is read is cached in memory.

## Memory

| Scene | CPU MB | GPU MB |
|---|---|---|
| 1,000 different avatars | 1,249.9 | 956.1 |
| 10,000 different avatars, stadium, LOD on | 6,876.7 | 1,524.6 |

`sona_stats` reports both figures at run time (`cpu_mb`, `gpu_mb`). Every avatar holds its own build, so memory
grows with the count of avatars, not of looks.

## What sets the numbers

| Setting | Where | Effect |
|---|---|---|
| Level of detail | `sona_lod_set` ([crowds](guides/crowd.md)) | Far avatars become sprites: fewer draws, less GPU time |
| Quality tier | `sona_tier_apply` ([tiers](guides/tiers.md)) | The low tier draws one sample, smaller faces, and poses small avatars at their clip's own rate |
| Anti-aliasing | `sona_renderer_set_quality` ([quality](guides/quality.md)) | MSAA samples cost GPU time on every avatar |
| Shadows and lighting | `sona_renderer_set_lighting` ([lighting](guides/lighting.md)) | A shadow pass per frame; proxy casters make it cheap for crowds |
| Build budget | `config.build_budget_ms` | How much of a frame the owner thread may spend committing loads |
| Worker threads | `config.worker_threads` | Decodes and builds run there; 0 runs them inside the build budget |
| Memory budget | `config.budget` | Caps the caches; `budget.total` is the hard limit |
| Vulkan features | `sona_renderer_vk_features` ([Vulkan features](guides/vulkan-features.md)) | Bindless textures and multi-draw cut CPU time per draw |

## Measure it yourself

`sona-bench` is in every native download (`bench/`) and prints the same JSON these tables are filled from. It reads
the avatar files from a folder (`--source dir:<folder>`), and random outfits need the catalogue:

```text
sona-bench --scene crowd --backend vk --source dir:<folder> --outfits random \
  --catalogue sona-catalogue.bin --counts 1000 --seconds 4 --out crowd.json
sona-bench --scene crowd --backend vk --source dir:<folder> --layout stadium --lod on \
  --counts 10000 --out stadium.json
sona-bench --scene cold --backend vk --source dir:<folder> --out cold.json
```

It reads the frame times from `sona_stats`, so your own game can log the same numbers. The speed gates each release
must pass are in [hardening](guides/hardening.md).
