fix(services/lib): defaults favour throughput; opt-in politeness; add sccache (#188) #190

Merged
mik-tf merged 1 commit from development_mik_build_perf_quickwins into development 2026-05-01 19:53:08 +00:00
Owner

The cargo invocation in svc_install used nice 19 ionice 3 -j 4 defaults
to protect live Hero services from build-storm. That made sense when
hero_proc had a chatty SQLite log store fighting cargo for I/O bandwidth
(hero_proc#85). With the SQLite→hero_log refactor (a2eff7c), that
contention is gone and the polite-defaults are just leaving CPU on the
floor. Verified live during the 2026-05-01 herodemo deploy: setting
HERO_CARGO_JOBS=0 mid-deploy took load avg from 1.14 to 15.22, with
iowait staying at 0-4% — the box is CPU-bound, and we were using ~6%
of available CPU.

Three changes, all behaviour-equivalent for callers that set the env
vars explicitly:

  1. Defaults flipped: HERO_CARGO_JOBS now defaults to 0 (cargo auto =
    nproc), HERO_CARGO_NICE to 0 (no priority adjustment),
    HERO_CARGO_IONICE_C to "" (skip ionice prefix entirely on the cargo
    invocation). Operators on live boxes that need politeness set
    HERO_CARGO_NICE=19 HERO_CARGO_IONICE_C=3 explicitly (same env vars,
    inverted defaults).

  2. New env: HERO_CARGO_SCCACHE (default "auto"). When sccache is
    available in PATH, RUSTC_WRAPPER=sccache is exported into the
    cargo build env. Shared compile cache across services means the
    second build of any common dep (axum, tokio, rustls, hyper, …)
    short-circuits to a copy. Big win on a service_install_all that
    compiles 22 services with overlapping dep trees. "1" = require
    (error if missing). "0" = disabled.

  3. ionice prefix is now skipped when HERO_CARGO_IONICE_C is empty,
    matching the macOS skip path. The build line print also shows
    sccache state ("[sccache=ON]") for operator visibility.

Verified: nu --ide-check returns only type hints, no parse errors.

Refs: #188

Signed-off-by: mik-tf

The cargo invocation in svc_install used `nice 19 ionice 3 -j 4` defaults to protect live Hero services from build-storm. That made sense when hero_proc had a chatty SQLite log store fighting cargo for I/O bandwidth (hero_proc#85). With the SQLite→hero_log refactor (a2eff7c), that contention is gone and the polite-defaults are just leaving CPU on the floor. Verified live during the 2026-05-01 herodemo deploy: setting HERO_CARGO_JOBS=0 mid-deploy took load avg from 1.14 to 15.22, with iowait staying at 0-4% — the box is CPU-bound, and we were using ~6% of available CPU. Three changes, all behaviour-equivalent for callers that set the env vars explicitly: 1. Defaults flipped: HERO_CARGO_JOBS now defaults to 0 (cargo auto = nproc), HERO_CARGO_NICE to 0 (no priority adjustment), HERO_CARGO_IONICE_C to "" (skip ionice prefix entirely on the cargo invocation). Operators on live boxes that need politeness set HERO_CARGO_NICE=19 HERO_CARGO_IONICE_C=3 explicitly (same env vars, inverted defaults). 2. New env: HERO_CARGO_SCCACHE (default "auto"). When sccache is available in PATH, RUSTC_WRAPPER=sccache is exported into the cargo build env. Shared compile cache across services means the second build of any common dep (axum, tokio, rustls, hyper, …) short-circuits to a copy. Big win on a service_install_all that compiles 22 services with overlapping dep trees. "1" = require (error if missing). "0" = disabled. 3. ionice prefix is now skipped when HERO_CARGO_IONICE_C is empty, matching the macOS skip path. The build line print also shows sccache state ("[sccache=ON]") for operator visibility. Verified: nu --ide-check returns only type hints, no parse errors. Refs: https://forge.ourworld.tf/lhumina_code/hero_skills/issues/188 Signed-off-by: mik-tf
fix(services/lib): defaults favour throughput; opt-in politeness; add sccache (#188)
All checks were successful
Build and Publish Skills / build-and-publish (pull_request) Successful in 4s
c27c49fb03
The cargo invocation in svc_install used `nice 19 ionice 3 -j 4` defaults
to protect live Hero services from build-storm. That made sense when
hero_proc had a chatty SQLite log store fighting cargo for I/O bandwidth
(hero_proc#85). With the SQLite→hero_log refactor (a2eff7c), that
contention is gone and the polite-defaults are just leaving CPU on the
floor. Verified live during the 2026-05-01 herodemo deploy: setting
HERO_CARGO_JOBS=0 mid-deploy took load avg from 1.14 to 15.22, with
iowait staying at 0-4% — the box is CPU-bound, and we were using ~6%
of available CPU.

Three changes, all behaviour-equivalent for callers that set the env
vars explicitly:

1. Defaults flipped: HERO_CARGO_JOBS now defaults to 0 (cargo auto =
   nproc), HERO_CARGO_NICE to 0 (no priority adjustment),
   HERO_CARGO_IONICE_C to "" (skip ionice prefix entirely on the cargo
   invocation). Operators on live boxes that need politeness set
   HERO_CARGO_NICE=19 HERO_CARGO_IONICE_C=3 explicitly (same env vars,
   inverted defaults).

2. New env: HERO_CARGO_SCCACHE (default "auto"). When sccache is
   available in PATH, RUSTC_WRAPPER=sccache is exported into the
   cargo build env. Shared compile cache across services means the
   second build of any common dep (axum, tokio, rustls, hyper, …)
   short-circuits to a copy. Big win on a service_install_all that
   compiles 22 services with overlapping dep trees. "1" = require
   (error if missing). "0" = disabled.

3. ionice prefix is now skipped when HERO_CARGO_IONICE_C is empty,
   matching the macOS skip path. The build line print also shows
   sccache state ("[sccache=ON]") for operator visibility.

Verified: nu --ide-check returns only type hints, no parse errors.

Refs: #188

Signed-off-by: mik-tf
mik-tf merged commit f379c13e39 into development 2026-05-01 19:53:08 +00:00
mik-tf deleted branch development_mik_build_perf_quickwins 2026-05-01 19:53:08 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_skills!190
No description provided.