cmds.secrets.lib.DistroContext: One SSH session per compile #183

Merged
Jan Lindemann merged 2 commits from jan/feature/20261120-cmds-secrets-lib-distrocontext-one-ssh-session-per-compile into master 2026-11-20 23:12:07 +01:00 AGit
Owner

The compile phase of a secrets deploy used to open a new SSH session per remote command and one file-listing round-trip per package; this PR holds the context and secret store open for the whole compile and batches the file listing into a single pkg_paths() call, so the deploy establishes one connection and lists all package files in one round-trip.

cmds.secrets.lib.DistroContext: Batch file listing code

The compile phase of a secrets deploy makes one SSH round-trip per package to list the package files. On a host with nine packages, that is nine round-trips.

Make match_files() pass the whole name list to pkg_paths() in one call: the distro backends already accept a list and issue a single file-listing command.

cmds.secrets.lib.DistroContext: Hold ctx + store open

Each run() call opens and closes the exec context, so a compile that issues one remote command at a time opened and closed the SSH connection for every command: a single deploy on dynamix opened around a hundred sessions and took several minutes.

run() opens and closes through the FileContext reference counter, so holding the context (and the secret store) open for the whole compile turns the per-command open() / close() pairs into counter bumps, and the connection is established only once. This commit wraps the target listing and the per-target loop in an async with on both, which drops the counter to zero at end of scope and closes the contexts.

The compile phase of a secrets deploy used to open a new SSH session per remote command and one file-listing round-trip per package; this PR holds the context and secret store open for the whole compile and batches the file listing into a single `pkg_paths()` call, so the deploy establishes one connection and lists all package files in one round-trip. #### cmds.secrets.lib.DistroContext: Batch file listing code The compile phase of a secrets deploy makes one SSH round-trip per package to list the package files. On a host with nine packages, that is nine round-trips. Make `match_files()` pass the whole name list to `pkg_paths()` in one call: the distro backends already accept a list and issue a single file-listing command. #### cmds.secrets.lib.DistroContext: Hold ctx + store open Each `run()` call opens and closes the exec context, so a compile that issues one remote command at a time opened and closed the SSH connection for every command: a single deploy on dynamix opened around a hundred sessions and took several minutes. `run()` opens and closes through the `FileContext` reference counter, so holding the context (and the secret store) open for the whole compile turns the per-command `open()` / `close()` pairs into counter bumps, and the connection is established only once. This commit wraps the target listing and the per-target loop in an `async with` on both, which drops the counter to zero at end of scope and closes the contexts.
The compile phase of a secrets deploy makes one SSH round-trip per package
to list the package files. On a host with nine packages, that is nine
round-trips.

Make match_files() pass the whole name list to pkg_paths() in one call: the
distro backends already accept a list and issue a single file-listing
command.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.2
Signed-off-by: Jan Lindemann <jan@janware.com>
cmds.secrets.lib.DistroContext: Hold ctx + store open
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m49s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 6m6s
CI / Packaging test (pull_request) Successful in 0s
7cec4007da
Each run() call opens and closes the exec context, so a compile that issues
one remote command at a time opened and closed the SSH connection for every
command: a single deploy on dynamix opened around a hundred sessions and
took several minutes.

run() opens and closes through the FileContext reference counter, so
holding the context (and the secret store) open for the whole compile turns
the per-command open() / close() pairs into counter bumps, and the
connection is established only once. This commit wraps the target listing
and the per-target loop in an "async with" on both, which drops the counter
to zero at end of scope and closes the contexts.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.5.2
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-11-20 22:50:02 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
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
janware/jw-pkg!183
No description provided.