Skip to content

perf: use dictionary index for community status satellite lookups - #97

Merged
magicbug merged 1 commit into
magicbug:mainfrom
g4dpz:optimise/community-status-dictionary-lookup
Aug 7, 2026
Merged

perf: use dictionary index for community status satellite lookups#97
magicbug merged 1 commit into
magicbug:mainfrom
g4dpz:optimise/community-status-dictionary-lookup

Conversation

@g4dpz

@g4dpz g4dpz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

TryGetMode and TryGetSatellite on SatelliteCommunityCatalog previously iterated the Satellites list linearly on every call (O(n)). These are called from the UI rendering path for each enabled satellite's status indicator (~10 lookups per tick at 4 Hz = ~40 linear scans/second).

Changes

Build a lazily-initialized Dictionary<string, SatelliteCommunitySatelliteStatus> keyed by satellite name (case-insensitive) on first access. Subsequent lookups are O(1). The index is built once per API fetch (every 5 minutes) and reused for all rendering ticks in between.

  • TryGetSatellite → single Dictionary.GetValueOrDefault call
  • TryGetMode → dictionary lookup for satellite, then short linear scan of modes (typically 1-3 modes per satellite)

Tests

All 42 existing SatelliteStatus tests pass unchanged.

TryGetMode and TryGetSatellite previously iterated the Satellites
list linearly on every call (O(n)). These are called from the UI
rendering path for each enabled satellite's status indicator.

Build a lazily-initialized Dictionary<string, ...> keyed by name
(case-insensitive) on first access. Subsequent lookups are O(1).
The index is built once per API fetch (every 5 minutes) and reused
for all rendering ticks in between.
@magicbug
magicbug merged commit 09faf5d into magicbug:main Aug 7, 2026
1 check 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.

2 participants