feat: aliae performance improvement for Windows cmd clink integration #151
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.
Prerequisites
Performance Issue Defined
The Lua script generated by Aliae uses multiple
io.popen
calls executed in serial. Eachio.popen
call takes 20ms when Clink is injected and 50ms when Clink is configured for autorun.As such, the more aliases you configure, the longer the delay when launching CMD with Clink. With 70 aliases, the Lua script takes 4-7 seconds to execute before the prompt is ready for input.
Proposed Solution
I propose the use of a Doskey macrofile, which will require only one
io.popen
call, greatly improving the performance with Clink on Windows to a near-instantaneous start time forcmd.exe
.The resulting Aliae syntax generated for clink looks like:
Side Effect / Breaking Change
Aliases making use of an ampersand (&) need to be specified differently when using a macrofile versus directly on the command line. As such, the yaml configuration for aliases using & would require updating.
Alias definitions in current state:
Would need to be updated after this code change:
Another benefit of the change to a macrofile allows for greater support of cross-platform aliases -- case in point the git alias above requires different syntax for windows in current state, but in the proposed future state, one alias serves many platforms.
A workaround to support the transition could involve simple string replacement of
^&
with&
to make the change non-breaking. I'm not a fan of hidden string manipulation, so I did not implement it in this PR; however, it could be an effective migration strategy to consider.Final Thoughts
I believe the performance improvement is worth the risk of a small, but easy to fix, breaking change.