Sixty-six profiles, one idle core: the gateway that would not sit still


Sixty-six profiles on one machine, each with its own skills tree, sessions and configuration. Nothing is running — no conversation, no job — yet the fans spin up and the gateway process holds a full core. Three and a half days later the Windows kernel pool reached 23.5 GB, commit charge pushed past 90%, and the page file had grown itself to 53 GB.

No model is thinking and no database is writing. This is filesystem metadata: opening directories, reading mtimes, resolving paths — work that produces almost no output, repeated tens of thousands of times a second.

The numbers below come from the reporter on issue #146538 (Windows 11, 62 GB RAM, 66 profiles). Treat them as a reproducible observation, not our own measurement. What I could check against main — which code paths are involved and what the caching policy is — I verified separately.

The symptom: an idle gateway doing constant file work

The measurement is simple: take io_counters().other_count on the gateway PID and watch the delta.

Sample Result
10 seconds 33,710 ops/s
157 seconds 44,689 ops/s
Fifteen-minute samples 55,000 to 99,000 ops/s

The next-highest process on that machine was Defender at roughly 10,000 ops/s; everything else stayed under 4,000. The fastest-growing kernel pool tags were FMfn (file-name entries, 5.4 to 6.2 GB, about 13.4 million live) and File (file objects, 4.4 to 5.3 GB, about 11.7 million objects against roughly 531,000 handles system-wide).

A 30-second py-spy sample at 50 Hz put about 64% of non-idle samples in filesystem calls, clustered on three stacks:

Samples Stack
258 skills_tool._dir_tree_signature ← _skills_scan_signature
182 hermes_constants.named_profile_has_identity ← profiles._iter_named_profile_dirs
176 profiles._iter_named_profile_dirs ← profiles_to_serve

Three scans that never stop

One: the skills directory signature. So that a skill you just installed shows up immediately and a disabled one disappears, Hermes computes a signature: every catalog directory’s mtime and child directory names, plus the disabled set and the platform. Computing it means walking the tree — _dir_tree_signature descends up to six levels (a skill sits at <category>/<sub>/<skill>/), and its own comment says about 1 ms for 170 directories.

One millisecond sounds harmless. The problem is frequency and multiplication: the signature has a 30-second cache TTL (_SKILLS_CACHE_TTL_SECONDS), and every profile has its own skills tree. Sixty-six profiles × a few hundred files each becomes a continuous, low-grade storm.

Two: profile re-enumeration. To know which profiles a gateway should serve, profiles_to_serve() reads the profiles/ directory and decides which entries are live, parked, or declared standalone. Deciding whether a profile “has an identity” means reading inside it (named_profile_has_identity). The cost grows linearly with profile count, and this path is called very often.

Three: uncached path resolution. Many call sites run Path.resolve() (or an equivalent realpath) to turn a relative path into an absolute one. On Linux the kernel’s caches absorb most of that; on Windows, resolving a path really does ask the filesystem. The second reporter — a nine-profile deployment — makes the point that the same code is roughly twice as expensive there, and what users see is a one-to-three second wait when switching bots.

Why more profiles costs more than linearly

Multiply the three: profiles × skill files per profile × call frequency. It is a product, not a sum, which is why nine profiles already feels slow and sixty-six pins a core.

The second data set in the thread shows the shape of it: nine profiles, 1,336 skill directories, about 500,000 sessions, gateway at 119% to 167% of one core while idle, and desktop bot switches taking one to three seconds. A finer observation from the same reporter: switching session tabs inside the launch profile is instant, while in any secondary profile every click shows a backend reload stall — because the per-profile scope is being rebuilt on each switch.

Measuring it yourself

You do not need a profiler for a first look:

import os, time, psutil

p = next(proc for proc in psutil.process_iter(["cmdline"])
         if "gateway" in " ".join(proc.info["cmdline"] or []))
a = p.io_counters().other_count
time.sleep(10)
b = p.io_counters().other_count
print(f"{(b - a) / 10:,.0f} metadata ops/s")

other_count does not mean exactly the same thing on Linux and macOS, so the more meaningful comparisons are idle versus busy on the same process, and how far ahead of the next-highest process it sits. To find the functions, sample with py-spy (py-spy record --pid <pid> --nonblocking) and check whether you land on the same three stacks.

What you can do today

To be clear: this is not fixed. The issue is open and the tracking PRs have not merged. Everything below reduces the damage; none of it closes the problem.

  1. Serve fewer profiles per gateway. A profile can declare gateway.standalone: true, after which the host gateway skips it; or you can park one with hermes -p <name> gateway stop, which the host also skips. If half of your sixty-six are experiments, this is the biggest single win. The wider pattern is in one gateway per host.
  2. Stop giving every profile a full skills tree. Fewer directories means a cheaper signature walk. Share common skills and keep only the truly profile-specific ones locally. Mechanics: hot-serve profiles.
  3. Do not copy someone else’s local patch. The reporter changed two things to prove the cause: the skills/projects/pairing scan interval from 2 s to 300 s, and a per-profile skills cache. He says plainly that these are his local changes and are not upstream. Treating them as official tuning is risky — a five-minute interval also means newly installed skills can take minutes to appear.
  4. Headless setups have a PR to watch. #146137 stops the watcher scan while no client is attached, which helps a gateway nobody is connected to. On a machine with the desktop app attached most of the day, the wins come from caching and intervals instead.

Older builds have had other skills-index problems too, such as truncation from over-long descriptions — see the skills index width post. Profile creation, export and deletion are documented in the hermes profile reference.

Status

Issue #146538 is open. It names three tracking PRs: #146137 (stop the watcher scan while no client is attached), #146562 (reuse category roots within one catalog scan — the reporter measured about 65% duplicated-root walking) and #146644 (retain parsed catalogs across passes). They are moving on main; none of them is in v0.23.4 (November 24).

If this is biting you, measure your own metadata ops per second first, then look at whether the profile count can come down. Cutting profiles is something you can do today; waiting for the fix is not.