Skip to content

Measure a baseline and a control arm for the RigForge refresh tick and verbs before porting #704

Open

Description

@pithead-developer

What's the problem

The case for a Rust port rests on cost nobody has measured. rigforge-api-refresh.timer fires every 15 s (OnCalendar=*:*:0/15 in systemd/rigforge-api-refresh.timer.template) and each tick runs $SCRIPT_DIR/rigforge.sh api-refresh (systemd/rigforge-api-refresh.service.template), which loads the roughly 6.2k-line rigforge.sh plus sourced utils and spawns many jq processes (_api_rigforge_block alone is one jq -n with many --argjson inputs). CPU time, peak memory and spawn count per tick are unknown, so the port cannot be judged, and any gain could be credited to Rust that a cheap shell fix would also deliver.

What it impacts

The decision to flip the default in the Rust port tracker (#669) and every later issue in it. Also rigs: a small always-on cost on mining hosts.

How I found it

Reading the timer and service templates and rigforge.sh (api_refresh, _api_rigforge_block, _api_refresh_status, _pool_conn_status, _tcp_probe) while scoping the Rust port, at ea41133. No measurement exists in the repo; #669 already makes the baseline the first deliverable. Benchmark method follows pithead#3811.

How important is it

High for the port, which cannot be justified without it. Low urgency otherwise. It changes no product behavior and unblocks the final flip decision.

Acceptance criteria

  • A committed script under tests/ or scripts/ measures, per run: CPU time, peak RSS and process-spawn count for one api-refresh tick, plus wall time for status, doctor --json and apply --dry-run.
  • Each measurement uses at least 5 interleaved repetitions and a discarded warm-up, reports median and spread, and states warm or cold cache.
  • Runs on a KVM guest and on a rig-class host, described by class only; no hostnames, addresses or paths appear in the committed report (make lint-topology passes).
  • Raw results and the exact commit measured are committed under docs/dev/rust-port/.
  • A control arm is measured: the cheapest change to the current Bash that targets the profiled hot spot (for example fewer jq spawns per tick). It is a measurement branch or patch, not merged unless the owner asks.
  • The report states what fraction of tick cost is interpreter startup versus jq and other spawns, or says it could not separate them.
  • make check passes.

Possible solutions

  • /usr/bin/time -v plus strace -c -f -e trace=execve (or perf stat) around one tick on the KVM guest; median of repeated runs.
  • A small sampler script modelled on the Pithead benchmark sampler in pithead#3811.
  • Unknown: how many ticks per day the cost actually matters for; the report should state it rather than assume.

Release: date 2026-12-04
Who: operator

Activity

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

    @pithead-developer
    ContributorAuthor

    Data points for the baseline, from a read-only audit of develop at f37640f5.

    Where What Result
    Linux container, files on local disk, idle host one api-refresh tick 214 external commands (jq 91, tr 62, dirname 16), 0.85 s wall, 0.87 CPU-seconds
    A 96-thread rig mining on every thread, v1.19.0 rigforge-api-refresh unit, systemd CPU accounting, last 40 runs mean 2.54 CPU-seconds per run (min 2.49, max 2.56), about 17% of one core at one run per 15 s
    Same rig rigforge-watchdog unit, last 20 runs mean 1.39 CPU-seconds per run
    Same rig status and control servers about 10 MiB resident each
    Linux container script start-up 13 ms to parse, 87 ms for version

    The rig figure is under full mining load, so it includes contention with the miner. The container figure is the idle floor.

    Not measured: peak RSS of a tick, an A/A noise floor, and a second rig.

    The spawn sources and a cheap shell control arm are listed in #818.

  4. added
    blocked
    on Nov 24, 2026
  5. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #847

    Status, 24 November 2026. For the refresh tick the baseline and the control arm exist:

    • Baseline: 285 started programs and 608 forks per tick on a fixture with two pools and 20 control outcomes.
    • Control arm: Each api-refresh tick starts more than 200 processes #818, in review. 100 programs and 206 forks, byte-identical output, about 2.7 times less CPU per tick in one interleaved container run.
    • Compiled stand-ins on the same inputs: about 50 times less CPU in C and about 30 times in Go.

    The next arm (a tick that does not redo unchanged work) and the readings on a rig-class host are tracked in #847. This issue waits for #847 so that no second harness is built. Left for this issue afterwards: wall time of status, doctor --json and apply --dry-run, the KVM guest run, and committing the script and the raw results.

  6. added
    operator-hold
    on Nov 24, 2026
  7. removed
    blocked
    on Nov 24, 2026
  8. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    ContributorAuthor

    Owner decision, 24 November 2026: the compiled refresh (#717) is built now, so this measurement is done now too. #847 no longer blocks it.

    Already measured, in one container session with the versions taking turns: started programs and CPU per refresh for today's shell, for the shell fix of #818 (the control arm this issue asks for), for a caching arm, and for single-process stand-ins in C, Go and Rust. The numbers are on #847.

    Still to do here:

    • commit the script with the raw results;
    • add peak memory, and wall time for status, doctor --json and apply --dry-run;
    • run it on a KVM guest and on a rig-class host, described without names.
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-healthoperator-holdperformancesize:Mtesting

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions