Skip to content

flyitalyadsb: --api-update-every, a faster API without writing the json files more often - #7

Merged
riccardosabatti merged 2 commits into
devfrom
flyitalyadsb-api-update-every
Nov 2, 2026
Merged

riccardosabatti merged 2 commits into
devfrom
flyitalyadsb-api-update-every

Conversation

@riccardosabatti

@riccardosabatti riccardosabatti commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Why. map.flyitalyadsb.com moves every 2 s at best (every 3–4.5 s over London, a user's screen recording on 2026-11-02, fixed separately in flyitalyadsb/tar1090#5). The map reads the readsb API (--tar1090-use-api), and apiUpdate rebuilds the API buffer every --write-json-every. Lowering that also rewrites aircraft.json and the 577 globe files every round: ~8.4 MiB, 4.2 MiB/s per cell today at 2 s, on a VM disk already writing ~25 MiB/s. The API update alone is cheap: api_update ≈ 0.04 core at 2 s (stats.json last15min).

Change: --api-update-every <sec>

  • apiUpdateEntryPoint waits api_interval instead of json_interval.
  • apiUpdate wakes the json writers (Threads.json, Threads.globeJson) once per json interval only, so the files keep --write-json-every. With equal intervals it wakes on every update, as upstream.
  • With --tar1090-use-api, receiver.json refresh is the API rate, which is what tar1090 polls (RefreshInterval = data.refresh).
  • Default = --write-json-every. Longer is clamped with a warning, since the API update is what wakes the writers.
  • The WITH_UUIDS recent-receivers window follows the update interval.

Readers of the double buffer (API workers, the two json writers) copy from the flipped buffer in milliseconds. A flip every 0.5 s gives them the same margin upstream gives at --write-json-every 0.5.

Test. flyitalyadsb/test-api-update-every.sh on a real binary, in a new workflow flyitalyadsb-test.yaml. It samples the API's now and aircraft.json's now for 8 s and takes the median gap between readsb's own timestamps:

  • 0.5 / 2 s: API every 0.5 s, aircraft.json every 2 s, refresh 500;
  • no option: both every 2 s, refresh 2000 (upstream behaviour);
  • --api-update-every 5 with 2: refresh 2000 and the warning.

Run locally, because CI can't run here: ubuntu:24.04 container, make (gcc, -Werror) + upstream make test + the new test:

api-update-every 0.5, write-json-every 2: API every 0.50 s, aircraft.json every 2.00 s
write-json-every 2 only: API every 2.00 s, aircraft.json every 2.00 s
ok

Negative check: with the json-wake gate removed (if (1 || …)) it fails with aircraft.json written every 0.50 s, expected 2.

⚠️ Actions is disabled on this repository (gh workflow run → HTTP 422 "Actions has been disabled for this repository", while actions/permissions says enabled). No run since 2026-10-29 11:52Z: no sync-upstream, no promote, no PR builds. Until it's re-enabled, merging this builds no canary.

Rollout. Merge → readsb-canary:canary on cell B. The option goes into nesso-infra's args only once cell A runs a stable that knows it, because an unknown option stops readsb. B first through gen_cell_b.py overrides, then both.

Riccardo Sabatti and others added 2 commits November 2, 2026 14:26
…on files more often

The map (tar1090 with --tar1090-use-api) can only be as fresh as the API
buffer, which apiUpdate rebuilds every --write-json-every. Lowering that also
rewrites aircraft.json and the globe tiles more often: on map.flyitalyadsb.com
~8.4 MiB per round, 4.2 MiB/s at 2 s, while the API update itself costs
~0.04 core at 2 s (stats.json, 2026-11-02).

--api-update-every <sec> sets the API update interval on its own:
- apiUpdateEntryPoint waits api_interval;
- apiUpdate wakes the json writers once per json interval only, so the files
  keep --write-json-every (equal intervals: every update, as upstream);
- with --tar1090-use-api, receiver.json "refresh" advertises the API rate,
  which is what the map polls;
- the WITH_UUIDS recent-receivers window follows the update interval.
Default: the write-json-every value; longer than that is clamped with a warning,
because the API update is what wakes the json writers.

flyitalyadsb/test-api-update-every.sh runs a real binary (flyitalyadsb-test.yaml):
0.5/2 s gives ~12 API updates and ~3 aircraft.json writes in 6 s and refresh 500;
without the option both stay at 2 s (refresh 2000); 5 > 2 is clamped and warns.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The first version counted distinct values in 60 samples and assumed 6 s, but
curl + python make the loop ~10 s, so it saw 17 API updates and 5 file writes
and failed a correct binary. Now it samples for 8 s of wall clock and takes the
median gap between readsb's own timestamps: 0.50 s API / 2.00 s aircraft.json
with --api-update-every 0.5, 2.00/2.00 without (ubuntu 24.04 container). With
the json-wake gate removed it reports aircraft.json every 0.50 s and fails.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@riccardosabatti
riccardosabatti merged commit 8236a4e into dev Nov 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant