Skip to content

Server administration

A Server runs campaigns for several Members from a queue. Members submit from their own machine with hfim run --on <server>; the Server builds, measures the golden run, injects and keeps the results until the Member fetches them. This page is for the administrator of that machine. Members read Running campaigns.

Components

Component One per Runs as Role
Gateway (fim-gateway@<account>) account fim-<account> Server API v1 on the Unix socket /run/fim-<account>/api.sock; the account's SQLite Ledger; health at /healthz
Worker fleet (fim-worker@<account>) account fim-<account> one unit, workers processes; each takes one Job from the queue
Redis (container fim-redis) Server container job streams and result streams
Public Endpoint (fim-public_endpoint) Server, optional root Server API v1 on a TCP port; checks the Access Token, forwards to the Member's Gateway socket

HFIM installs and operates all of them with two commands: hfim server install and hfim server update. The server/ directory of this repository holds the code, the systemd units (deploy/systemd/) and manifest.yaml, which tells HFIM what to run.

Install

On the server, from a Linux administrator account, install hfim and then the Server:

pipx install hfim-cli    # the PyPI package; it installs the hfim command
hfim server install

hfim server install is part of hfim, so hfim must be installed on the server itself, not only on the laptops. Without pipx, use a virtual environment: python3 -m venv ~/hfim && ~/hfim/bin/pip install hfim-cli, then run ~/hfim/bin/hfim server install.

Requirements

The host needs Linux, Git, Docker Engine with Compose, and network access to the release feed and image registry. The default member connection uses OpenSSH. The command requests sudo when run from an administrator's login. A campaign account or access token grants no server administration privileges.

Steps

On a fresh host, the command installs the Docker release, creates the queue and an account named after the administrator's login, and starts its gateway and workers. It verifies the release manifest, package checksums and Docker image digest. Preview with hfim server install --dry-run. Run sudo hfim doctor on the server to check its health.

The default plan lives at /etc/hfim/server.yaml. Edit it to change accounts, worker counts or access, then run hfim server install to apply it. Existing installations keep their deployment form. On a fresh systemd host, hfim server install --native selects system services and builds the simulator locally. Native builds also need the compiler, Python headers and simulator build tools listed by preflight.

To use a private release feed, put its stable manifest URL in /etc/hfim-release-url, owned by root and writable only by root. Docker uses the host administrator’s registry credentials.

For a custom backend or a development build, supply your own checkout with hfim server install --native /path/to/hfim-server --no-update. Place the matching SDK and simulator checkouts next to it. Private source URLs require credentials readable by the administrator running the install.

First campaign

Give the member SSH access under the server's access policy. On their machine, using their SSH login and the account socket selected by the administrator:

hfim remote add myserver --transport ssh-tunnel --set ssh=<login>@<host> \
    --set socket=/run/fim-<account>/api.sock --credential peer
hfim doctor --on myserver

From an exported RV64 starter, run hfim run --on myserver campaigns/fibonacci.yaml.

Where a Server keeps its files

A Server keeps its files in the directories below. hfim server install refuses a host that already has a fim directory beside one of them.

Path Holds Grows with
the workspace the checkouts and the hfim that runs the install; any directory each HFIM version
/etc/hfim/ the Server Plan, the Server Lock, the env files and the secrets nothing
/opt/hfim/ the Server Releases, the Active Release .venv, the Machine Registry home/ and the native simulators sim/ each release and simulator version
/srv/hfim/users/<name>/ each account's Ledger, uploads, Run Trees and results the campaigns
/srv/hfim/keys/<name>/ the key pair of an account with no ssh_key: nothing
/var/lib/hfim/redis/ the Redis data and user list the queue
/run/fim-<name>/ the Gateway socket nothing

To keep /opt/hfim or /srv/hfim on another disk, mount that disk at the path before the first install. The paths then stay the ones above, and nothing else changes.

The form (--native or --docker) is chosen on the first install only; a Server keeps its form.

Exit code Meaning
0 done, or nothing to do
1 refused; the message names the fix
2 usage error
3 prerequisites missing
4 health check failed; rolled back
5 drain time limit reached; nothing changed

Simulators

simulators: in the Server Plan lists the simulator packages of the Server. hfim server install and hfim server update look up the newest release tag of each one and, when the Machine Registry /opt/hfim/home lacks that version, build it in native form into /opt/hfim/sim/<package>/<version> and register it there. The versions installed before stay, for the campaigns and templates that pin them. The dry run names the version:

would install hfim-sim-qemu-xuantie@9.0.2, its newest release, in native form into the Machine Registry /opt/hfim/home

A checkout of the same name in the workspace is built when it holds that release; otherwise the install clones the tag. /opt/hfim/sim is the HFIM_NATIVE_ROOT of the Server's machine environment; a Member's own computer keeps native builds in ~/.hfim/sim. A Member's campaign names the package and version it needs (simulator: hfim-sim-qemu@9.2.4); hfim doctor --on <server> checks that the Server has it.

In the native form a benchmark builds with the compiler its package declares (sdk.toolchains in the package manifest), from the package's prefix bin/ or from PATH. A declared compiler the host lacks is a missing prerequisite: the install refuses with exit code 3 and prints the install command, for example sudo apt install gcc-riscv64-unknown-elf for riscv64-unknown-elf-gcc. A package whose install brings its own compilers declares runtime.native.compilers: bundled and needs none on the host; hfim-sim-qemu-xuantie does. sudo /opt/hfim/.venv/bin/hfim doctor checks the compiler of every installed version, and says to rebuild a package whose bundled compiler is gone.

Package In the default plan Build A campaign on the Server
hfim-sim-qemu yes QEMU and its plugin, several minutes, with the simulator build tools of the requirements its injections spread over the worker fleet
hfim-sim-qemu-xuantie no the XuanTie fork of QEMU, its plugin and XuanTie's compiler, about two minutes on an x86-64 Server as hfim-sim-qemu; the template nezha-c906-qemu pins it
hfim-sim-gem5 no DRAMsim3 and the two gem5 binaries (classic caches and Ruby MESI), about one hour, with the packages of Add gem5 one Campaign Job: the whole campaign runs on one worker

Add hfim-sim-qemu-xuantie

The nezha template runs on the XuanTie fork of QEMU, the only QEMU with the C906 model c906fdv. XuanTie publishes its compiler for x86-64 Linux only, so in the native form the package installs on an x86-64 Server only.

  1. Add it to the plan. In /etc/hfim/server.yaml, add the package to simulators:. A plan the install wrote has one package per line; both YAML forms mean the same:
simulators:
- hfim-sim-qemu
- hfim-sim-qemu-xuantie
simulators: [hfim-sim-qemu, hfim-sim-qemu-xuantie]
  1. Preview, then install. From a native source workspace with access to the simulator repository. The step simulator:hfim-sim-qemu-xuantie@9.0.2 builds the package from its newest release tag; the other steps report nothing to do.
cd /path/to/workspace
sudo --preserve-env=SSH_AUTH_SOCK venv/bin/hfim server install hfim-server --no-update --dry-run
sudo --preserve-env=SSH_AUTH_SOCK venv/bin/hfim server install hfim-server --no-update
  1. Check.
cd /opt/hfim/home && ls simulators/hfim-sim-qemu-xuantie    # prints 9.0.2
ls /opt/hfim/sim/hfim-sim-qemu-xuantie/9.0.2/bin | grep -c riscv64-unknown-elf    # XuanTie's compiler is there

Use 9.0.1 or later on a Server. 9.0.0 built its plugin against another QEMU's header when installed natively, and every golden run failed with QEMU process exited immediately with code 1; run by hand, QEMU says plugin requires API version 4, but this QEMU supports only up to version 2.

Upgrade a simulator package by hand

Managed installations use the simulator versions pinned by the release. For a custom source deployment:

Server What happens What to do
native form, no access to GitHub the install prints <package>: its newest release is not known (...); the versions installed stay, and one is installed by name if none is copy a checkout of the release into the workspace and build it, below
docker form the Server Image holds the packages, built from the checkouts next to hfim-server when an update stages a new Server Release check out the release tag in that checkout before hfim server update

On a native Server, from the workspace that holds the checkout:

cd /path/to/workspace
sudo env HFIM_HOME=/opt/hfim/home HFIM_NATIVE_ROOT=/opt/hfim/sim HFIM_RUNTIME=native \
    venv/bin/hfim sim install hfim-sim-qemu-xuantie --path hfim-sim-qemu-xuantie --no-update
(cd /opt/hfim/home && ls simulators/hfim-sim-qemu-xuantie)    # 9.0.1 and 9.0.2

The three variables point the install at the Server's Machine Registry and native builds, as the install command does. The older version stays: a campaign that pins it keeps running. Members move to the newer one with hfim template update and hfim setup on their own computer.

An offline install from a checkout and a Docker-form simulator upgrade have not been verified.

Add gem5

Every step runs on the Server, in the native source workspace.

  1. Install the gem5 build packages. hfim-sim-gem5 builds on the image ghcr.io/gem5/ubuntu-22.04_all-dependencies:v23-0. The list below is that image's (gem5/util/dockerfiles/ubuntu-22.04_all-dependencies/Dockerfile in the package), without its documentation and lint tools, plus gcc-riscv64-linux-gnu, the compiler hfim-sim-gem5 declares for its benchmarks:
sudo apt install build-essential git m4 scons zlib1g zlib1g-dev libprotobuf-dev protobuf-compiler libprotoc-dev libgoogle-perftools-dev python3-dev libboost-all-dev libhdf5-dev python3-pydot libpng-dev libelf-dev pkg-config python3-venv gcc-riscv64-linux-gnu
scons --version
  1. Add it to the plan. In /etc/hfim/server.yaml, the simulators: line becomes:
simulators: [hfim-sim-qemu, hfim-sim-gem5]
  1. Preview, then install. The step simulator:hfim-sim-gem5@23.2.0 clones the release tag and runs the package's install.sh: it clones and builds DRAMsim3, then builds both gem5 binaries with 8 parallel jobs. The other steps report nothing to do.
sudo --preserve-env=SSH_AUTH_SOCK venv/bin/hfim server install hfim-server --no-update --dry-run
sudo --preserve-env=SSH_AUTH_SOCK venv/bin/hfim server install hfim-server --no-update
  1. Check.
cd /opt/hfim/home && ls simulators/hfim-sim-gem5    # prints 23.2.0

The prerequisite check of the install covers the QEMU build tools and the compiler of each package, not the gem5 build packages. A missing gem5 package fails the simulator:hfim-sim-gem5@23.2.0 step, for example with scons not found, and the install stops there; the running Server keeps its state. hfim-sim-gem5 is built and tested in the environment of its image, Ubuntu 22.04 with GCC 11 and Python 3.10. A native build on another distribution uses that distribution's compiler and Python.

Run a gem5 campaign on the Server

On a Member's computer, a repository made with hfim init nezha-c906-gem5 holds gem5 campaigns (Nezha C906 on gem5). hfim run --on <server> sends one as any other campaign. The Server runs it as one Campaign Job on one worker; its injections are not spread over the fleet. Fault targets, CPU models and caches: gem5 backend.

These server install and submission steps have not been verified end to end for gem5. A native gem5 build on Debian 13 with GCC 14 and Python 3.13 is also unverified.

Server Plan

/etc/hfim/server.yaml, version 1. An unknown key is refused with its name.

version: 1
form: native
access:
  accounts: true          # Account Isolation: one Linux user per Member
  identity: true          # Identity Check
  port: null              # host:port adds the Public Endpoint
accounts:
  researcher:
    workers: 30
    ssh_key: /etc/hfim/keys/researcher.pub
  student:
    workers: 6
simulators: [hfim-sim-qemu, hfim-sim-qemu-xuantie]
machine_env: {}
ssh_tunnel: true
redis:
  url: null
drain_minutes: 30
Key Values Default Effect
form native, docker chosen at first install systemd units or containers
access.accounts true, false false Account Isolation; false allows exactly one account
access.identity true, false true the Gateway checks who connects; accounts: true needs identity: true
access.port host:port or null null starts the Public Endpoint on that address
accounts.<name> name matching ^[a-z][a-z0-9]{1,30}$ the Admin Account one Member; no dash in the name
accounts.<name>.workers integer, 1 or more 1 size of the worker fleet
accounts.<name>.ssh_key path to a public key none installed for fim-<name>; without it the Server makes a key pair
simulators package names [hfim-sim-qemu] built with hfim sim install in native form into HFIM_HOME=/opt/hfim/home; see Simulators
machine_env name: value empty environment for every account; an absolute path must exist. A change re-applies every account: each is drained and restarted
ssh_tunnel true, false true on Linux writes /etc/ssh/sshd_config.d/50-hfim.conf: group fim-users gets local stream and TCP forwards only
redis.url URL or null null Redis the fleets use; null is the container fim-redis that the install starts
drain_minutes integer, 0 or more 30 how long install and update wait for running Submissions; 0 is no limit

Warning

RISCV_CC in machine_env names one compiler for every benchmark of every account, and it comes before the compiler each simulator package declares. The Server then builds other ELFs than a Member's computer builds for the same campaign, so the two results do not compare. Install the compiler each package declares instead (Requirements).

Access Policy

accounts identity port Combination Who reaches the Gateway
false true null single user members of group fim-users, through the socket
false false null trusted lab any local user
true true null account isolation only the account's own uid, through its socket
false true set token on a port, shared a valid Access Token, to the Default Account
true true set token on a port, isolated a valid Access Token, to that Member's Gateway
false false set open port anyone who reaches the port

Warning

identity: false with a non-loopback port accepts any client that reaches the address. hfim server install prints a warning for it.

Accounts

Add an account

  1. Add the account under accounts: with access.accounts: true.
  2. Preview on the server:
hfim server install --dry-run
  1. Apply: the same command without --dry-run.

hfim drains the accounts it has to restart, waits until they are idle, then:

  1. creates the Linux user fim-<name> in group fim-users and its User Base /srv/hfim/users/<name>/;
  2. installs the public key from ssh_key:, or makes an ed25519 pair in /srv/hfim/keys/<name>/ for the administrator to hand over;
  3. writes the systemd slice with the account's resource limits;
  4. makes the account's Redis ACL user and its password file /etc/hfim/<name>.redis (mode 0600, owner the account);
  5. writes /etc/hfim/<name>.env, starts the Gateway and the workers and checks their health.

A second run with the same plan prints nothing to do.

Change the fleet size

Edit workers: and run the install command of Add an account. The slice limits follow the new count.

Remove an account

Delete the account from accounts: and run the install command of Add an account. Its units stop and its Redis user is removed. The User Base, Ledger, results and ssh key stay.

Delete a removed account's data hfim never deletes Member data. Deleting it is a separate, manual decision, run from the `server/` directory of the HFIM checkout:
sudo ./add-user.sh <name> --remove

User isolation

Mechanism Effect
process identity every unit of an account runs as fim-<name>; files it writes are owned by that user under a mode-700 home
Gateway socket /run/fim-<name>/api.sock in a runtime directory owned by the account; the Gateway takes the Member from the socket peer (SO_PEERCRED)
object ownership every request names objects of the caller only; another Member's object answers 404, as a missing one does
queue namespace FIM_QUEUE_NS=<name>: streams campaign_jobs:<name> and results:<name>, consumer group fim-workers:<name>
Redis ACL user fim-<name> reaches only its own two streams and only the commands hfim-server issues
job signing the Gateway signs every job with a per-account key; a worker refuses a job that does not verify
resource slice Gateway and workers run in fim-<name>.slice
Public Endpoint header X-HFIM-Member is trusted only from a root peer, the Endpoint itself

Resource limits

Slice Covers CPUQuota MemoryMax TasksMax
/etc/systemd/system/fim-<name>.slice Gateway and workers workers x 100% workers x 1024 MB + 512 MB 256 + workers x (128 + 2 x nproc)
/etc/systemd/system/user-<uid>.slice.d/limits.conf the Member's ssh sessions workers x 100% workers x 1024 MB workers x 20 + 10

TasksMax counts threads. Too low a value shows up as EAGAIN on fork. Reaching MemoryMax kills a QEMU process, which the campaign reports as crash; raise workers rather than lower the memory limit. The docker form sets the same totals as compose limits.

systemctl status fim-<name>.slice
systemctl show -p ControlGroup fim-worker@<name>

Account directory

/srv/hfim/users/<name>/
└── v1/
    ├── blobs/<2 hex>/<64 hex>                 uploaded content, by sha256
    ├── workspaces/<ws>/snapshots/<64 hex>.json
    ├── workspaces/<ws>/runs/<submission id>/  one Run Tree per Submission
    ├── workspaces/<ws>/golden/, builds/       shared by Record Key
    └── logs/<submission id>.log

The v1 root is FIM_V1_ROOT, else <User Base>/v1.

Workers and queue

How a Submission runs

  1. hfim run --on sends the files the Server lacks as blobs and submits a Snapshot Manifest.
  2. The Gateway records the Submission in the account Ledger and writes a Run Tree.
  3. A worker takes the Preparation Job: hfim prepare --json in the Run Tree, which builds, measures the golden run and takes the checkpoint as the staleness rules decide.
  4. The Gateway releases Injection Jobs, each run_campaign --inject-index I --campaign-id CID --golden-key K, under the campaign's Concurrency Cap.
  5. The Job that completes the campaign's count consolidates injections.csv and the summary.
  6. The client follows the event stream and fetches results/<campaign_id>/, checking every file against its hash.
Job One per Command
prepare Submission hfim prepare --json per campaign (--build-only for hfim build --on)
inject injection run_campaign --inject-index I
campaign campaign the whole campaign, for a backend without an inject-index path (gem5)

Every Job runs with HFIM_WORKSPACE (Builds and Goldens shared by Record Key), HFIM_CAMPAIGN_MACHINE (neutral provenance entries such as the Server Release) and the Submission's forwarded environment. A cancelled Submission starts no Job; a running Job is killed with its process group.

Concurrency

The Concurrency Cap of a campaign is floor(min(host cores, workers) / harts). The Ledger releases injection indices inside one write transaction, so two workers that finish together cannot pass the cap. num_workers and --workers in a campaign do not apply on a Server.

hfim doctor warns when the sum of workers over all accounts is above the CPU count.

Fleet down

With no live worker the Gateway refuses new Submissions with no_live_worker. A Submission never falls back to running inside the Gateway.

Snapshots

Every submit freezes the campaign's ELF, benchmark directory and golden directory under $FIM_WORK_ROOT/campaigns/<cid>/inputs. inputs/ is removed when the campaign reaches a terminal state. At startup and every six hours the Gateway removes campaigns/<cid> directories older than FIM_SNAPSHOT_RETENTION_DAYS (default 7, 0 disables) whose campaign is done, failed or cancelled.

Updating

On the server, an administrator runs:

hfim server update

HFIM selects the current release from the configured feed, stages it alongside the active release, drains submissions, and checks the gateway and workers after the switch. If the new services fail to start or pass health checks, HFIM attempts to restore the previous release. The command reports whether recovery succeeded. Run hfim server update --dry-run for a preview.

Members run hfim update on their own machine to update their CLI. Updates to shared services require root or sudo on the host.

For a source deployment, use hfim server update /path/to/hfim-server --no-update to select the checkout and the core version installed in the administrator's CLI.

Option Effect
--dry-run print the steps and the files that would change
--no-update use the checkout as it is, without pulling
--force cancel running Submissions or leave unfetched ones behind, printing each id

Drain writes /etc/hfim/drain/<account>; the Gateway then answers new Submissions with 503 server_draining. hfim waits up to drain_minutes for idle. At the limit it lifts the markers, changes nothing and exits 5.

Taking the Server down

hfim uninstall refuses on a Server. The steps that remove the accounts, the services, the files and the images are in Uninstalling: On a Server.

Monitoring

On the Server:

Check Command
plan, drift, health of every account, with the fix of each failure sudo /opt/hfim/.venv/bin/hfim doctor
the same as JSON sudo /opt/hfim/.venv/bin/hfim doctor --json
one Gateway sudo curl -s --unix-socket /run/fim-<name>/api.sock http://localhost/healthz
Redis sudo docker ps --filter name=fim-redis
units of one account systemctl status fim-gateway@<name> fim-worker@<name>
worker log journalctl -u fim-worker@<name> -f

hfim doctor changes nothing on the Server. It needs root to open the Gateway sockets; without it every account reports [Errno 13] Permission denied. It recomputes the hash of every file hfim wrote and reports each one that changed by hand. Its lines above server: describe root's own registry /root/.hfim.

Files on the Server

Path Content Access
/etc/hfim/server.yaml Server Plan root, edited by the administrator
/etc/hfim/server.lock what is installed, with file hashes root; users read
/etc/hfim/<name>.env the account's env file, read by Gateway and workers; holds no secret 0644
/etc/hfim/<name>.redis the account's Redis password 0600, owner the account
/etc/hfim/redis.pass Redis admin password 0600 root
/etc/hfim/provision/account.env machine environment and socket access values, input of the account script root
/etc/hfim/endpoint/tokens.json SHA-256 of each Access Token 0600 root
/etc/hfim/drain/<name> drain marker root
/etc/hfim/backup/ backups of files hfim replaced root
/opt/hfim/releases/<id>/ Server Releases (HFIM and hfim-server) read-only
/opt/hfim/.venv link to the active release read-only
/opt/hfim/home HFIM_HOME of the Server: simulator registry and hfim-sdk read-only for users
/opt/hfim/sim HFIM_NATIVE_ROOT of the Server: the native simulator builds read-only for users
/var/lib/hfim/redis Redis data root
/srv/hfim/users/<name>/ User Base 0700, owner the account
/srv/hfim/keys/<name>/ key pair made by the Server root

What Members need

Give each Member the values for one Server Entry. The Member runs hfim remote add once; hfim doctor --on <server> then checks the route, the credential, the API version, the HFIM version, live workers and the pinned simulator.

Over ssh

Value Example
login fim-<name>@<server address>; without Account Isolation, a login in fim-users such as the Admin Account
Gateway socket /run/fim-<name>/api.sock
private key the pair from /srv/hfim/keys/<name>/, or the Member's own key named in ssh_key:
site note network prerequisites, for example a VPN
hfim remote add <server> \
    --transport ssh-tunnel \
    --set ssh=fim-<name>@<server address> \
    --set socket=/run/fim-<name>/api.sock \
    --set 'options=["-i", "~/.ssh/fim-<name>"]' \
    --credential peer

The account's key line allows only the Unix socket forward that hfim run --on uses.

Over the Public Endpoint

With access.port set, issue a token on the Server and hand it over once:

sudo /opt/hfim/.venv/bin/hfim-server token issue <name>     # prints the token once
sudo /opt/hfim/.venv/bin/hfim-server token list
sudo /opt/hfim/.venv/bin/hfim-server token revoke <name>

hfim-server is the command of the Active Release. It needs root because /etc/hfim/endpoint/tokens.json is mode 0600, owner root.

The Member stores it in the system keychain, through the keyring package:

hfim remote add <server> --api http://<host>:<port> --transport direct --credential keychain --no-check
hfim remote login <server> < token.txt
hfim doctor --on <server>

The Endpoint serves TLS when FIM_ENDPOINT_CERT and FIM_ENDPOINT_KEY both name existing files. The install writes neither, so the URL of an Endpoint it installed starts with http://.

Notifications

A Member stores a Telegram target with hfim remote notify <server> --telegram --chat-id <id>. The Gateway sends one message when a Submission ends, with its state and the outcome counts of each campaign.