Skip to content

Each api-refresh tick starts more than 200 processes #818

Done

Description

@pithead-developer

What's the problem

The 15-second timer runs api_refresh (rigforge.sh:5209), which calls the whole parse_config (:420-797) every tick, then builds several JSON documents with many small jq calls.

  • _warn_unknown_config_keys (:758) starts tr per config key per known key and its output is discarded.
  • parse_config reads about 30 scalar keys with one jq each.
  • _api_control_history_json (:5204) runs one jq per outcome file, up to 20.
  • _cpu_eff_khz (:4877) runs cat once per core.
  • The tail of api_refresh runs about 7 jq passes over the same body.

What it impacts

Every mining rig pays a steady cost on a machine whose cores are meant to mine. The cost grows with the number of config keys and cores.

How I found it

Measured. One tick started 214 external commands in a Linux container (jq 91, tr 62, dirname 16), about 0.87 CPU-seconds. On a fully loaded 96-thread test rig the unit's own accounting showed a mean of 2.5 CPU-seconds per run over 40 runs, about 17% of one core at one run per 15 seconds. A second fixture (20 control outcome files, 64 cores) counted 240, of which parse_config was 158 (95 tr, 61 jq). Unknown: how much of a tick is interpreter start-up versus spawns.

Code references are from develop at b7bf3b1. Checked for an existing issue: none found (complements #704, which asks for a baseline and a control arm, and #717, the port; this supplies measured numbers and a cheap-shell candidate for the control arm, it does not replace either).

How important is it

Medium. A constant, avoidable load that scales with rig size, but no behaviour is wrong.

Acceptance criteria

Possible solutions

  • Lowercase in the shell (${k,,}) instead of tr; this alone removes about 62 spawns.
  • Read plain keys with one jq ... | @tsv; skip the typo lint when the tick sets the tolerate flag.
  • Build the control history once when it changes; read -r v <"$f" instead of cat; one jq for the tail.
  • ${k,,} needs Bash 4, newer than macOS ships; rigforge.sh also has no line slack under docs/dev/file-budget.tsv, so changes must be line-neutral or cut elsewhere.

Activity

  1. added this to the v1.20.0 milestone on Nov 24, 2026
  2. added
    performance
    on Nov 24, 2026
  3. added
    operator-hold
    on Nov 24, 2026
  4. removed
    operator-hold
    on Nov 24, 2026
  5. pithead-developer commented on Nov 27, 2026

    @pithead-developer
    ContributorAuthor

    Waiting on a transient bench_outage condition, not on another issue. tier4-e2e submit on head 0372478 refused: bench-ci control plane at the configured BENCH_CI_URL refuses connections — bench-ci health/tiers each exhaust 5 read retries with 'request failed: <urlopen error [Errno 61] Connection refused>'; the host answers ping but the service port is CLOSED/REFUSED (nc -z). No job was created. The runner re-checks it (first at 2026-11-27T07:52Z, at most 5 times).

  6. pithead-architect commented on Nov 27, 2026

    @pithead-architect

    Release regroom (owner request, 2026-11-27): moved from v1.20.0 to v1.23.0. Trimmed from v1.20.0 (update API only) per the owner. Perf, hardening and measurement group.

  7. pithead-developer commented on Nov 28, 2026

    @pithead-developer
    ContributorAuthor

    Merged in #848.

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

    performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions