GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Optimize SSH file transfer by batching uploads by diegolovison · Pull Request #780 · Hyperfoil/Hyperfoil Conversation
|
| Files | scp (Baseline) | scp with array |
|---|---|---|
| 1 | 336 ms (1.0x) | 292 ms (1.15x faster) |
| 10 | 3235 ms (1.0x) | 533 ms (6.07x faster) |
| 100 | 33482 ms (1.0x) | 3243 ms (10.32x faster) |
| 1000 | 319168 ms (1.0x) | 32844 ms (9.72x faster) |
Reproducer. You need to remove the files because there is a checksum in the code to prevent copying again.
rm -fR /home/dlovison/.m2/repository/io/hyperfoil/hyperfoil-clustering
rm -fR /tmp/hyperfoil/
mvn clean package -Pbenchmark
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1000 files is not just 89% faster than the existing approach 🙏 Use the ratio as a measure of improvement |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Here is the raw data and ratio.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@franz1981 CI was complaining. We were unlucky, and then I reduced the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
| if (!fileToUpload.isEmpty()) { | ||
| try { | ||
| scpClient.upload(fileToUpload.toArray(String[]::new), dir + AGENTLIB + "/", |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
maybe we want to have a configurable amount of connections?
The scp changes are now using a single connection instead of 1 per file, but maybe we can have 10 connections for 100 files etc etc no?
The default can still 1 but people can change it, with a max == total number of files (so you can have the default behaviour with -1 or 0 - what fit best)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can it be a percentage?
Because the total number of files is going to change from release to release.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think we can add if really needed. Otherwise, it is one more scenario to maintain. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't want to assume 1 connection fit all yet: you tried on your machine only so far no? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Usually you want to setup the number of physical resources required; a percentage is dangerous as it can grow a lot...while if you tell people to setup 1000 they probably think twice than 100% without knowing that hyperfoil jars can be 200.. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ok. Let's use the number of connections. Example:
Should 1 be the default? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
only if we can check on the CI how it behaves... |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
How about keeping by default a connection per file (no extra parameter), and if someone sets the parameter |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
that's the current behavior you mean? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The current behavior is that all files are in a single connection. My proposal is to change the default behavior to keep it as it was before this PR
Then, introduce a new parameter. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
TBH I was thinking it was creating a new connection per each file - instead. Batching on the other side batch ALL files to a single scp connection |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The current code (before your PR) does not put all files in a single connection. It calls scpClient.upload(file, remote) inside a loop — and each call is blocking: it opens a new SCP channel, transfers the file, waits for the ACK, and closes the channel before the next iteration starts. So with 1000 files, you get 1000 sequential channel-open/transfer/close cycles. Your PR collects all files into a list and calls scpClient.upload(files[], remote) once — one channel, all files streamed through it back-to-back, no repeated handshake overhead. That's where the 10x is coming from, likely (to verify it!). My suggestion at this point is NOT to make it configurable, as the old behavior was just wrong. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@franz1981, what you describe is accurate.
That is good! Ready to merge? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Well done!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
But check if there are hidden timeout on scp now that the single connection run for longer please 🙏 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I don't see any timeout, and all tests are passing. If there are timeouts ( like before this change ), the test will fail ( like it was on my computer ) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I mean; check the scp wrapper library default timeout as we need to make sure they want fall shortly based on the available bandwidth. We need them to be enlarged to accomodate to the larger quantity of files sent |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.