-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ssh): optimize traversing ssh config includes #976
Conversation
5a0b540
to
0853f8c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! These are style and minor changes.
0853f8c
to
3d89182
Compare
@akinomyoga Implemented the requested changes.
This fails the tests, because single |
Thank you for pointing this out. Hmm, so it means that each element of the resulting array of |
3d89182
to
c19daf3
Compare
Renamed the variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for quick responses and updating!
These are cosmetic ones. With these addressed, I'd approve it.
c19daf3
to
447e925
Compare
Applied the requested changes. |
As per ssh_config man, "Files without absolute paths are assumed to be in ~/.ssh if included in a user configuration file or /etc/ssh if included from the system configuration file." So relative include base stays the same throughout recursion, even if the system-wide config is included from user's config. This commit also optimizes traversing ssh config includes. Previously each config file was read with separate `sed` command to extract `Include` directives. This can get quite slow if there are a lot of included files. Instead of reading each individual file, we can put all the files at a current recursion level into a single sed invocation and extract all the directives in one go.
447e925
to
4ac86e8
Compare
Looks mostly good to me, added a comment about the "16" to make it less magical. However, the commit message seems to talk about an actual fix in addition to a performance improvement, whereas the PR title here and the commentary seems to refer only to the perf improvement. If there's a fix in here, could we add a test case showcasing what was broken before this and fixed now? Or if there's no fix, could we rephrase the commit message some to clarify that? Also, if there's no actual fix here, the conventional commit type would be better set as |
Story about a fix is hidden in the resolved diffs. Basically the problem we found during discussion was that if a user config file included some config in I don't know how to add a test for this, since the scenario involves creating an ssh config file somewhere under
Original commit message was about perfomance improvement (that's probably the more interesting part anyway, since the failing scenario seems extremely unlikely). However @akinomyoga suggested that it would be changed to talk about the include fix. Should I change it back? |
There is a fix. At least the commit changes the behavior, so, in my opinion, we should mark it as Actually, the ideal way is to separate the commit into the |
Ideally yes, but in this particular case it will be difficult. There are two possible commit orderings:
I support marking commit as "fix". Or maybe we can mark it as "fix,perf"? |
For me it's optional to separate the commit; I wouldn't request you to separate it. But if you are willing to separate the commit, either option works. If it were me, I think I'd use option 1. |
I really don't want to separate it :) |
Ok, merged as is. Thanks! |
Previously each config file was read with separate
sed
command to extractInclude
directives. This can get quite slow if there are a lot of included files (on my machine it was ~0.4s for each TAB keypress).Instead of reading each individual file, we can put all the files at a current recursion level into a single sed invocation and extract all the directives in one go.