Skip to content

Port the api-refresh tick to Rust #717

Open

Description

@pithead-developer

What's the problem

Every 15 s the whole Bash script loads to run api_refresh, which assembles summary.json, summary-authed.json, health.json and tune.json from _api_rigforge_block, _health_json, _watchdog_json, _api_tune_json, _api_power_json, _api_config_json, _api_control_history_json, _api_refresh_status, _pool_conn_status and _tcp_probe, plus util/revision-key.sh. This is the hot path and the main place a performance claim could be earned.

What it impacts

The sister feed that Pithead and LAN clients read; CPU and memory on rigs; the contract fixtures tests/contract/v1/feed.json and feed-authed.json.

How I found it

Reading systemd/rigforge-api-refresh.service.template and the functions above at ea41133. Per-tick cost is unmeasured (see #704), so this must not start before that issue reports.

How important is it

Medium; value depends on the baseline.

Acceptance criteria

  • The PR links the Measure a baseline and a control arm for the RigForge refresh tick and verbs before porting #704 report and states the expected saving versus the control arm.
  • Any feed field added by merged v1.19 or v1.20 issues is covered by a contract fixture before the port.
  • With RIGFORGE_IMPL=rust, rigforge.sh api-refresh runs the native tick and the generated feed files byte-match tests/contract/v1/feed.json and feed-authed.json after the same normalization the suite applies.
  • make test-suite passes unchanged under RIGFORGE_IMPL=rust, honoring the sandbox env hooks (MEMINFO, GOVERNOR_FILE, RAPL_DIR, SERVICE_NAME, RIGFORGE_REVISION_KEY, API_CMD, PATH-stubbed externals).
  • Output files are written atomically exactly as today; a failed probe degrades to the same health values pinned in tests/contract/v1/README.md.
  • The Measure a baseline and a control arm for the RigForge refresh tick and verbs before porting #704 script is rerun at this head; CPU time, peak RSS and spawn count per tick are reported against the baseline and the control arm, including a null or negative result.
  • PARITY.md updated. make check passes.

Possible solutions

Release: issue rigforge#716 closed
Who: operator

Activity

  1. added this to the v1.20.0 milestone on Nov 17, 2026
  2. added
    enhancement
    performance
    P4-code-health
    size:L
    on Nov 17, 2026
  3. added
    blocked
    on Nov 24, 2026
  4. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #847

    Owner direction, 24 November 2026, for the compiled tick:

    Findings from a design pass against the test stack, for whoever builds it:

    • A version the existing tests can check is about 3,000 lines in any compiled language. By the rule above that is Rust, as this issue says.
    • 2 tests run the tick as a command and 20 call api_refresh in process. With the hand-over inside that function and the shell variables exported, 12 of the 20 can reach a binary with no test edited. 8 replace helpers and stay shell-only, for the ledger.
    • The binary must start curl, systemctl, journalctl and dmidecode by name through PATH, or the stand-ins in the suite stop working. About 8 started programs per tick remain.
    • New variables in the unit template fail the existing check for unexpanded placeholders. A systemd drop-in avoids that.
    • A cautious binary that hands unusual configs back to the shell gains nothing on a rig whose config is unusual. Classify real configs before a unit is switched.
    • Timing stand-ins on the same inputs: about 50 times less CPU than the shell in C and about 30 times in Go. They skip checks the shell makes.
  5. added
    operator-hold
    on Nov 24, 2026
  6. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #704
    Blocked on #716

    Owner decision, 24 November 2026: build the compiled refresh now, in Rust, ahead of its place in the shipping order. This replaces the direction in the comment above.

    Measured first, in one container session with the versions taking turns (CPU per refresh against today's shell): the shell fix of #818 uses 2.2 to 2.4 times less, a caching version on top of it 4.7 to 5.4 times less, and a single compiled process 45 to 50 times less in Rust or C and about 30 times less in Go. Rust and C are equal within noise. The numbers and the method are on #847.

    Order of work, under the ground rules of #669:

    The default stays bash. Nothing here changes what a rig runs until the switch is set. #847 no longer blocks this issue: a compiled refresh needs no cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4-code-healthblockedenhancementoperator-holdperformancesize:L

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions