Repository navigation
Conversation
plajjan
reviewed
Nov 6, 2026
Signed-off-by: Antonio Prcela <antonio.prcela@sartura.hr>
ScpPut and ScpGet copied every received chunk with `_rx += chunk`, even when _rx was empty, so every downloaded byte was allocated twice. A pending timeout timer keeps its actor alive until it fires, which for ScpPut includes its reference to data. RunCommand, ScpPut and ScpGet mark their timeouts with a TODO to cancel the timer once Acton supports cancelling timers. The new bench_scp shows what a finished ScpPut keeps: it prints the live GC heap after each of a series of uploads. Measured downloading 1000 MiB over 1 Gbit: GC allocation per byte downloaded 2.02 -> 1.02. Signed-off-by: Antonio Prcela <antonio.prcela@sartura.hr>
Signed-off-by: Antonio Prcela <antonio.prcela@sartura.hr>
channel_finalize cleared the context's actor pointer but kept its callbacks, and the context stays on the client's retired_channels list until the client finalizes. Each callback refers to the actor that uses the channel, so every finished RunCommand, ScpPut or ScpGet stayed in memory, with everything it refers to, for as long as its Client was open. server_channel_finalize did the same with the session's retired_channels and the actor behind a ServerChannel's callbacks. Both now clear the callbacks after the last delivery. A queued message holds its own reference to the callback it calls, and every reader of these fields checks for NULL. A finished consumer can still stay in memory: it and its Channel refer to each other, and Channel's __cleanup__ registers a GC finalizer, so the GC never collects the pair.
ScpGetScaleTester downloads a file of t.scale() MiB once per t.loop() body, so acton test scale and acton test perf can measure how the time and the GC allocation of a get grow with the file size. Ordinary testing makes one 1 MiB get. It is a scenario of ScpTester and uses its sshd. dd makes the file as a hole that reads as zeros, so the remote scp reads no disk blocks, and the client turns compression off, so the zeros cross the link at full size. Once the loop runs, the scenario's 25 s timeout no longer applies: a perf run can take longer, under the test runner's watchdog. The loop binds next() to a variable before isinstance, because the compiler calls next() twice in isinstance(next(it), just). Up to 256 MiB on a laptop, a get took about 11 ms plus 2.3 ms per MiB and allocated 1.03 bytes per byte received.
ScpFanoutScaleTester connects t.scale() Clients, at most 64 at a time, because sshd's listen queue holds 128 connections and macOS resets the ones past it. The test's sshd_config sets MaxStartups to 100, since the default refuses some unauthenticated connections past 10. Each t.loop() body then puts the same 8 MB on every Client at once and waits for all of them, so acton test scale shows how the time, the GC allocation and the peak RSS grow with the number of Clients. The peak RSS includes libssh's send buffers, which are outside the GC heap. Up to 64 Clients on a laptop, a body took about 12 to 15 ms per Client and allocated under 0.7 MiB in all, so no Client copies the data. The peak RSS grew by about 0.55 MiB per Client. With 1024 Clients a body took 33 s and allocated 7.3 MB, and the peak RSS was 430 MB. The scale scenarios now share loop_next, which starts the next t.loop() body. Co-authored-by: Antonio Prcela <antonio.prcela@sartura.hr>
The step runs ScpGetScaleTester under acton test perf at 50 MiB and fails when the average GC allocation per loop body is above 1.1 bytes per byte received. Locally it measured 1.02 to 1.03, also with 14 busy loops beside it. Each download arrives in 32 KiB chunks, and each chunk costs its copy plus about 1 KiB, so 1.1 fails when a chunk costs about 2 KiB more. Smaller files are noisier. acton test perf does not fail on a change, so jq checks the allocation in its JSON report. A skipped or failed test has no measurement, and the step fails then too.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ScpPutandScpGetcopy one file over SCP on an existingClientwithout blocking. They run the server'sscp -t/scp -fon an exec channel and implement the protocol in Acton, because libssh'sssh_scp_*blocks.The branch also adds:
example_scp_clientexample_scp_multi(sends one file to many devices)bench_scptest_scp(tagopenssh)ScpPutwrites the whole file at once, so the file must fit inmax_write_buffer(0 for no limit). Pass the samebytesto every upload and the file is in RAM only once.C changes
ssh_channel_write()call writes at most 256 KiB, not up to the peer's window (OpenSSH: 2 MB). Whatever the kernel didn't take used to wait in libssh's send buffer.ACTON_SSH_WRITE_CALL_MAX=16777216restores the old behavior.benchmarks
bench_scpover a 1 Gbit/s LAN. The link is the limit (about 111 MiB/s), so any extra cost would show in CPU time.retain: 5 uploads of 1000 MiB withtimeout=600. The table shows the live GC heap after each upload. The pending timeout timer used to keep each upload's data alive.After is with commit 6d2d5c8 and 37f9c00
get: 5 downloads of 1000 MiB.ScpGetused to copy every received chunk an extra time.fanout: 50 sessions upload the same 500 MiB buffer to/dev/nullat the same time. "Old" setsACTON_SSH_WRITE_CALL_MAX=16777216; "new" uses the 256 KiB default.One 2000 MiB upload: the cap means 8 times as many write calls.
To reproduce:
Testing
acton test --min-time 2000 --max-time 10000 --tag openssh): 61 of 62 tests pass.InteropSshdShellNoPtyTester, failed in non-English locales, wherettyprints a translated message. It now runsLC_ALL=C ttyand passes.test_scpcovers:scpmax_write_bufferClientLimitations
-p.ulimit -n, and use IP addresses, because hostname lookup blocks.