# Improve demodulator speed :id=top

------

> _Doc Ver:_ 1.3  
_App Ver:_ 2.6.6.53  
_Date:_ 09/09/2026

------

> SA1 2.x (`sa-di` + `sa-web`) field notes: how to raise **sample rate**, how to raise **demodulation throughput**, and **which settings slow demodulation**. This is not GTK / RTLinux tuning and not SA2 / 3.x.

Related: [Frequency setting](frq_set.md) · [Data save](data_save.md#demod) · [Quick calculation](quick_calcs.md) · [Virtual sensors](vss.md) · [Warnings](warnings.md) · [Data filtering](data_filting.md) · [High-capacity save](large-data-store.md)

------

## 1. Two different rates :id=two-rates

People say “sample rate” and “demod speed” as if they were one knob. On SA1 they are two layers:

| Name | What it is | Where to see / change it | What happens if you raise it |
|------|------------|--------------------------|------------------------------|
| **Hardware sample rate** | How often the optical module / mainboard sends frames to UDP **8190** | Menu > **Monitor** > **Service**, frequency number on the bottom row; click the link to change. See [Frequency setting](frq_set.md) | Frames arrive denser. If software cannot keep up, **UDP packets drop**, the list jumps, save misses frames, the host sees gaps |
| **Software demodulation throughput** | How fast `sa-di` can turn 8190 frames into wavelengths, compute physical values, then report / save / refresh the list | There is no single “demod Hz” control. You free the pipeline: fewer extras, a faster parser, less disk, fewer transfers | Only when this keeps up does the list’s “physical-value output frequency” approach the “device sample frequency” |

**Correct order when you want a higher sample rate:**

1. Turn off or step down the software load (sections 3–8).
2. Then set the hardware frequency on the Service page.
3. Open **Monitor > List** and check that the four counters at the top left stay aligned (section 9). If they do not, lower the hardware frequency or cut more software load. Do not only crank the frequency number.

At 50 Hz and below, formula cost is usually not the limit. At 100 Hz and above you must use quick calculation (type `0`) and keep virtual sensors, alarms, filtering, and raw save off unless you need them.

------

## 2. What happens to one frame :id=pipeline

The mainboard sends spectrum / peak frames to local UDP **8190**. `sa-di` roughly does:

**receive → convert to wavelength → merge / compute physical values → report, write disk, feed the web UI.**

Save has three very different costs (Menu > **Setting** > **System** > **Base** > **Data save**, or **Data** > **Realtime save**):

| Kind | Page item | Which thread writes | Effect on demod |
|------|-----------|---------------------|-----------------|
| **Wavelength wl** | 1.8 Save wavelength | A separate save thread. Convert only signals “a frame is ready” | Almost no block. The ring is small. A slow disk **drops saved frames**, not demod frames |
| **Physical value pv** | 1.9 Save physical value | **The same thread that just computed**, synchronous write | Invisible on a fat machine (many-core Xeon, tens of GB RAM). Hurts on slow eMMC / low MHz. Mode `1` skips compute entirely, so it is faster |
| **Raw** | 1.10 Save raw | **The 8190 receive thread**; rotate may gzip while holding the lock | **Worst.** Blocks receive, the socket drops, convert and PV starve |

Compress (1.7) runs on a **separate pack thread**, not on convert. Fine on fat x86. On a single-core ARM board with about 256 MB RAM, zip steals CPU / RAM / writeback and the list and demod slow together. BusyBox may even add swap when memory is that small. Off-box send is **csdfu**, not sa-di.

**Mode 2** (full-speed sa-ds) hands high-rate write to sa-ds. In-box compute stays off unless 1.9 is on and “3.2 Frequency” runs a slow calc. Lower 3.2 if you want maximum save rate.

------

## 3. Machine class :id=machine

The same checkboxes differ by an order of magnitude on different hardware.

| Class | Typical box | Save that usually does not hurt demod | Turn off first if you need more |
|-------|-------------|----------------------------------------|----------------------------------|
| **Fat x86** | Many-core Xeon, tens of GB RAM, load near idle. Field-representative class | Enable, mode `0`, frequency `0`, wl + pv, zip on, **raw off** | You rarely need to drop wl/pv for demod. Drop raw, extra transfers, and the spectrum page |
| **Thin ARM / small RAM** | One or few cores, about 256 MB, eMMC | Do not run raw + zip + pv + a 100 Hz list together | **Raw and zip first**; then drop 1.9 or use mode `1`; then virtual sensors / filter / alarm |

Do not expect a 256 MB board to keep up at kilohertz with full-speed save + gzip + PV + list refresh at 100 Hz + the spectrum page open.

SA1 and SA2 are mutually exclusive. Both want UDP **8190**. Running `sa_daq` and `sa-di` together, or two `sa-di`, wrecks sample and demod. Stop the other stack before a rate test. Do not `killall -9`.

------

## 4. Which settings affect demodulation :id=affect

Heavier items first (turn these off first in the field):

| Prio | Setting | Path | When on | To go faster |
|:--:|---------|------|---------|--------------|
| 1 | Two stacks / two `sa-di` | Processes | They fight for 8190; frames drop, frequency jumps | Exactly one `sa-di` and one `sa-web`. See [Start, check, upgrade](operate.md) |
| 1 | **1.10 Save raw** | Data save | Receive thread writes disk; zip makes it worse | Leave **unchecked** unless you need a packet capture |
| 1 | Formula parser type `3` (and virtual sensors) | System > Base > Formula parser; Virtual sensor | Every frame uses the slowest interpreter; VSS defaults to type 3 | Use type `0` when you do not need VSS. See §6 |
| 2 | Heavy formulas, cross-sensor refs, `max`/`min`/stats | Sensor formula; VSS | Long compute per frame | Prefer type-0 fixed modes over type-3 expressions |
| 2 | Warning / alarm enable | Setting > Warning > Warning | Every frame (or a “data length” window) compares thresholds and slew | Uncheck **1.1 Enable** if you do not need alarms |
| 2 | Data filtering enable | System > Advanced > Data filtering | Every frame drops peaks in a channel/wavelength window; also applies to transfer and save | Off unless you must hide built-in or bad peaks |
| 2 | TCP report + source UDP + fan CMS together | Setting > Data transfer | Several encode/send paths on the same compute | Keep **one** egress. See §7 |
| 2 | High list refresh (default can be 100 Hz) | Setting > Web > List view > 1.2 | The UI hammers the device port | Set `5` while tuning rate |
| 2 | Spectrum page open | Monitor > Spectrum | Spectrum frames are much larger than wavelength; browser and gateway work harder | Close spectrum while tuning; leave a list or close the browser |
| 3 | Save 1.7 compress | Data save | Pack / gzip steal CPU and disk | Uncheck on a thin box. Zip is usually fine on fat x86. Off-box send is csdfu, not sa-di |
| 3 | Mode `0` with 1.9 Save physical value | Data save | Extra write on the compute thread | Fine on fat boxes. On thin boxes use mode `1` or uncheck 1.9 |
| 3 | Extra Monitor services (backup, FTP, report, …) | Monitor > Service | CPU, disk, network | Disable services you are not using |
| 3 | Fan CMS | Data transfer > Fan CMS | Extra protocol and trigger checks | Off when you are not talking to CMS |
| 4 | Hardware frequency above what software can follow | Monitor > Service bottom frequency | 8190 drops; counters disagree | Cut software load first, then set frequency; lower it if counters split |
| 4 | Many browser tabs / a phone page polling hard | — | Web reads also hit the port | One list page while you tune |

**These do not raise the optical-module frequency:** list refresh, UDP interval, save frequency. They only decide whether software keeps up and how often you send or write. Hardware frequency is only the Service-page number.

**Save does not always block demod.** Wavelength is off-thread; raw is on receive; pv is on compute. See [Data save · Does save slow demod?](data_save.md#demod).

------

## 5. Disable unrelated services (first step) :id=disable

Keep only what you actually need. Each enable adds work on the compute path.

### 5.1 Disable virtual sensors

Path: Menu > **Setting** > **System** > **Base** > **Virtual sensor**

1. Uncheck **1.1 Enable**.
2. Click **Save**.

While on, virtual sensors use formula-parser **type 3** (slowest). Redundant averages and channel stats go through this path. See [Virtual sensors](vss.md).

### 5.2 Disable data filtering

Path: Menu > **Setting** > **System** > **Advanced** > **Data filtering**

1. Uncheck **1.1 Enable**.
2. Click **Save**.

The filter also applies to transfer and save. Use it only to hide built-in or bad peaks. Sensors that reference variables may need a reconfigure after you turn it on. See [Data filtering](data_filting.md).

### 5.3 Disable warning / alarm

Path: Menu > **Setting** > **Warning** > **Warning**

1. Uncheck **1.1 Enable**.
2. Click **Save**.

While on, every frame (or a “2.2 Data length” window) compares left/right thresholds and slew rate. A larger data length is a heavier check. See [Warnings](warnings.md).

### 5.4 Disable other Monitor services

Path: Menu > **Monitor** > **Service**

1. Open each extra enabled service.
2. Uncheck **Enable**, click **Save**.
3. Turn off auto-backup, FTP upload, and report-style services while you tune rate.

------

## 6. Formula parser: how to compute faster :id=parser

Path: Menu > **Setting** > **System** > **Base** > **Formula parser** (some menus say “Formula interpreter”)

A higher type can express more, and is **slower per frame**.

| 1.1 Type | Capability | Speed | When to use |
|----------|------------|-------|-------------|
| **0** | Quick calculation. Only the fixed formulas in **2.1 Mode** | **Fastest** | **First choice** at 50 Hz and above, fans, and any rate push |
| **1** | `+ - * / ()` | Fast | Simple linear expressions without a fixed mode |
| **2** | Arithmetic plus `abs acos sin tan ceil cos exp floor fmod log max min pi sqrt` | Slow | Only when you need those functions |
| **3** | Full functions and arbitrary sensor-wavelength references | **Slowest** | Virtual sensors and cross-sensor formulas. Types 0 and 1 **cannot** compute VSS |

**To raise demodulation speed:**

1. Set **1.1 Type** to `0`.
2. Set **1.2 Frequency** to `0` (no cap; compute at the system maximum). A value `n` caps compute at n Hz: list PV thins out, but receive and wavelength still follow the hardware rate.
3. Set **2.1 Mode** to the row that matches the field formula (table below). Wavelength difference only: `1`.
4. Fan V2: mode `3`, keep **2.2 Data offset** at `1540000`. Do **not** set type to `3` (that is the slow interpreter; an older fan page said this wrongly).
5. Fan V3: mode `4`. Fan V4 / CMS: mode `5` (the CMS page requires the same).
6. Click **Save**.

| 2.1 Mode | Meaning |
|----------|---------|
| 0 | `w` realtime wavelength |
| 1 | `w-wl0` or `x`, wavelength difference |
| 2 | `tc*(w-wl0)+t0`, linear temperature |
| 3 | Fan V2: `w-1540000-TC*(w-wl0)` |
| 4 | Fan V3: `w-wl0-TC*(w-wl0)` |
| 5 | Fan V4 / CMS: same-channel temperature `tc*x+t0`, strain `(x-tc*$1)/k` |

At 50 Hz and below you usually do not need quick calculation and will not see delay. A 100 Hz fan **must** use type `0`. See [Quick calculation](quick_calcs.md), [Fan sensor V2](fan_v2.md), [Fan CMS](cms.md).

------

## 7. Data transfer: send faster without starving demod :id=transfer

Path: Menu > **Setting** > **Data transfer**

Four blocks: **Report via TCP**, **Report via UDP**, **Source UDP**, **Fan CMS**. Several at once steal from each other. Keep **one** when you push rate.

Interval fields are **microseconds** (1/1_000_000 s). `0`–`10` means almost no wait: send at the demodulator’s maximum.

### 7.1 Fastest physical-value send

1. Turn off **Report via TCP**, **Source UDP**, and **Fan CMS**.
2. On **Report via UDP**, check **1.1 Enable**.
3. Check **1.2 Use single server** and put the real host IP in **1.3 Server IP** (not a leftover example address).
4. Set **1.5 Interval** to `0`–`10` (µs).
5. Click **Save**.

TCP handshakes and retransmits; the same payload is heavier than UDP. CMS adds a fan protocol. Leave them off unless you must use them.

### 7.2 Fastest raw-wavelength send

1. Turn off **Report via TCP**, **Report via UDP**, and **Fan CMS**.
2. On **Source UDP**, check **1.1 Enable**.
3. Check **1.2 Use single server** and enter the host IP. Single-server is faster than broadcast / many targets.
4. Set **1.6 Interval** to `0`–`10` (µs).
5. Click **Save**.

**2.1 Enable low-speed calculation:**

- **Checked** (common): still compute PV, the list still updates, send is a bit slower.
- **Unchecked:** the device stops computing PV, send is faster, **the page physical values stop updating**. Uncheck only when a host takes wavelengths and you do not watch the list.

For PC saData high-speed binary receive: enable Source UDP, interval `10`, extension `0`, **Precise time control must be off**, and **close the browser management page**. See [High-capacity high-speed data save](large-data-store.md).

### 7.3 Fan CMS

When you must talk to CMS: formula parser type `0`, frequency `0`, mode `5`, then enable **Fan CMS**. Do not also enable TCP report and Source UDP. See [Fan CMS](cms.md).

------

## 8. Data save: write fast without hurting demod :id=save

Path: Menu > **Data** > **Realtime save**, or **Setting** > **System** > **Base** > **Data save**. Full item list: [Data save](data_save.md).

### 8.1 Fastest on-box save that still tracks demod

1. Check **1.1 Enable**.
2. Set **1.4 Frequency** to `0` (no extra interval; save at demod maximum). A value `n` writes about n Hz: easier on disk, thinner files.
3. **1.6 Mode:**
   - `0` normal: write wl/raw first, compute as usual; with 1.9 on, write pv after compute; list refreshes. Daily choice on a fat machine.
   - `1` no compute: wl/raw only; ignores 1.9; list does not refresh. Use when you want faster than `0` and do not need in-box PV.
   - `2` full-speed sa-ds: give CPU to high-rate write. See [Data save · full speed](data_save.md#configure_fs). With 1.9 on, compute at **3.2 Frequency**; lower 3.2 to interfere less with high-rate save.
4. **1.7 Compress file:** **uncheck** on a thin box or when you push demod. Compress steals CPU at rotate; raw gzip is worse. On fat x86, zip usually does not show up as a demod drop.
5. Off-box send is **csdfu** (Data save group 2, or `/csdfu` → `:8787`). sa-di no longer curls; do not run a second uploader on the same dir while tuning rate.
6. **1.8 Save wavelength:** check if you want wl files. Off-thread; lightest on demod.
7. **1.9 Save physical value:** check when you want pv and mode is `0`. Extra write on the compute thread. On a thin box, turn it off or use mode `1`.
8. **1.10 Save raw:** **leave unchecked** while you raise sample rate. On only when you need the UDP capture; then keep zip off if you can.
9. Click **Save** (writes `/var/sa/conf/data_save.json` and `:SYS:RELOAD`).

### 8.2 Extra items for mode 2

- **1.5 Cache count:** about 5–10× the sample rate.
- **1.2 Row count:** size files from frame length; compressed files are about 1/10 of raw.
- Group 3 ports (3.1–3.10) must be filled in order; no empty hole in the middle.

On-box storage is small. Row count, file count, and zip must be set together. A full disk stops or rotates writes; that is not the same as “demod Hz”.

------

## 9. Web refresh, spectrum, and the four counters :id=ui

### 9.1 Lower list refresh

Path: Menu > **Setting** > **Web** > **List view**

1. Set **1.2 Refresh frequency** to `5` (Hz, range 1–100; factory can be a high value).
2. Click **Save**.

This only reduces how often the UI hits the device port. It **does not change hardware sample rate**. While you tune rate or a host is receiving, close the browser or leave one list — cleaner than spectrum plus several tabs.

### 9.2 Spectrum is heavier than wavelength

Menu > **Monitor** > **Spectrum** pulls spectrum frames (much larger than a peak list) and the browser draws them. **Close the spectrum page** when you push sample or save rate. Use it to inspect peaks or channel thresholds, then close it.

### 9.3 Four counters: did software keep up?

Path: Menu > **Monitor** > **List**, jumping numbers at the top left, left to right:

1. **Device counter** — frame sequence on the hardware / demod side.
2. **Web-read tick** — how often the browser actually read (capped by §9.1).
3. **Physical-value output frequency** — rate after compute and outbound PV.
4. **Device sample frequency** — current hardware sample rate.

**Success looks aligned:** item 4 is the Hz you set; item 3 should be close to item 4 (unless you capped parser frequency, used mode `1`, or turned off source-UDP low-speed calc). If item 3 is clearly below item 4, software is behind: work down the §4 table, or lower the Service-page frequency.

The Service page bottom also shows save counter and save frequency. Save frequency stuck below sample frequency: disk or zip cannot keep up (wavelength save drops **saved** frames). If item 3 drops at the same time, look at raw / mode-0 pv write / zip.

------

## 10. Recipes by goal :id=recipes

### 10.1 Raise hardware sample rate and keep the web UI following

1. Section 5: off virtual sensors, filter, alarm, extra services.
2. Section 6: parser type `0`, frequency `0`, mode matching the field formula.
3. Section 9: list refresh `5`, close spectrum.
4. Data save: disable 1.1 if you do not need files; if you do, disable 1.10; on a thin box also disable zip.
5. Data transfer: all off if you are not sending to a host.
6. Then change frequency on the Service page. Watch the four list counters.

### 10.2 Host should get physical values as fast as possible

Steps 1–3 of 10.1, then §7.1 (UDP report only). Disable save if you can.

### 10.3 Host should get raw wavelengths as fast as possible

Steps 1–3 of 10.1, then §7.2 (Source UDP only). If you do not need on-box PV, uncheck **2.1 low-speed calculation**. Use saData for high-rate files and close the browser.

### 10.4 Densest on-box files without dropping demod

- **Fat x86:** mode `0`, frequency `0`, 1.8 + 1.9, 1.10 off; zip ok.
- **Thin ARM:** mode `1` (or mode `0` without 1.9), frequency `0`, 1.8 only, **zip off, raw off**.
- **Maximum write, in-box PV optional:** mode `2`, 1.9 off, 3.2 as low as you can. See [Data save · full speed](data_save.md#configure_fs).

### 10.5 Keep a UDP raw capture

1.10 is the only way. Demod may drop. Keep zip, spectrum, and extra transfers off. Turn 1.10 off as soon as you have the capture.

------

## 11. Short checklist (same menus as the older page) :id=checklist

Same menus as the historical help. “Why” is in the sections above.

### 11.1 Disable unrelated services

Same as §5: virtual sensors, data filtering, warning, extra Monitor services.

### 11.2 Fastest algorithm parser

Path: Menu > **Setting** > **System** > **Base** > **Formula parser**

1. Set **1.1 Type** to `0`.
2. Set **2.1 Mode** to `1` (wavelength difference). Use 3 / 4 / 5 for fans.
3. Click **Save**.

### 11.3 Lower Monitor list refresh

Path: Menu > **Setting** > **Web** > **List view** → **1.2 Refresh frequency** = `5` → **Save**.

### 11.4 Application-specific

- Physical-value send: §7.1.
- Raw-wavelength send: §7.2. Unchecking low-speed calculation stops page PV updates.
- Data save: §8.1. In-process high-speed save is mode `0` or `1`, not old 1/2. Mode `2` is full-speed sa-ds.

------

## Change log :id=changelog

|Version|Date|Description|
|:--:|----|----------|
|1.3|09/09/2026|1. sa-di curl upload retired; off-box send is csdfu.|
|1.2|09/08/2026|1. Hardware sample rate vs software throughput. 2. Pipeline, machine class, three save paths, settings table, and recipes. 3. Fan V2 is type 0 + mode 3, not type 3.|
|1.1|09/07/2026|1. Mode is 0 / 1 / 2. High-speed in-process save uses 0 or 1, not old 1/2.|
|1.0|03/03/2022|1. Created the help page in the new file format.|

------

[Top](#top)
