Re-implemented appendContent to persist a file handle and use Stream.IO.StreamWriter
for writing.
#36
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.
This is a preliminary reimplementation of the
appendContent
function insidewinrmcp/cp.go
. This aims to improve performance by reducing the system calls that Powershell will need to make when appending to a file.When using an i/o redirect, Powershell will need to allocate a handle when opening a file, seek to its end, write the relevant data, and then close the handle. Another negative effect of redirections is that by default it will use UTF-16 which requires twice as many bytes as UTF-8. This PR fixes the deterimental effects of a i/o redirect by using UTF-8, and using the lower-level
Stream.IO.StreamWriter
class from the .NET framework. This will result in the file handle remaining kept open during the process of the writing of the base64 hunks so that less system calls will need to be made in the hopes that things will be a little faster.I hate being the guy that uses channels for everything, but I wanted to keep the scope of the variable containing the
Stream.IO.StreamWriter
within a single function, and a channel seemed the best way to do this. :-/ I believe the same amount of data is being transferred over the socket, however the cost of file writing should be significantly reduced. Maybe it'll have an impact..This is based on the second suggestion I made in PR #6. It also hasn't been tested too well, and I haven't tested its performance at all as it's just an implementation of a theory. It is also significantly more complex than PR #35 and thus more work could probably be done if you guys believe it should be considered.