[Improvement] Cache user auth and converted paths for child-processes
Devste Devste
devstemail@gmail.com
Sun Jan 19 12:56:36 GMT 2025
strace -o strace.log dirname -- /some/path/here
There are 2 points that could make it significantly faster and
shouldn't be too hard to implement?
1) A significant amount of time is spent on user auth (as seen in
various github issues the infamous /etc/passwd nsswitch.conf fix)
Wouldn't it be possible to just reuse the auth data from the current
shell for the subshell, e.g. for
basename -- $(dirname -- /some/path/here)
2) why are unix/dos path conversions of environment variables not
cached? A significant amount of time (15-30%, depending on the number
of environment variables) is spent on the conversion for every
invocation.
However, this would be extremely simple to cache and reusable even on
completely unrelated subshells.
cache key = original path
cache value = converted value
e.g.
```
44 12839 [main] dirname 16929 mount_info::conv_to_posix_path:
conv_to_posix_path (C:\Users\User123\bin, 0x10000100, no-add-slash)
44 12883 [main] dirname 16929 normalize_win32_path:
C:\Users\User123\bin = normalize_win32_path (C:\Users\User123\bin)
44 12927 [main] dirname 16929 mount_info::conv_to_posix_path:
mount[0] .. checking / -> C:\Program Files\Git
44 12971 [main] dirname 16929 mount_info::conv_to_posix_path:
mount[1] .. checking /bin -> C:\Program Files\Git\usr\bin
44 13015 [main] dirname 16929 mount_info::conv_to_posix_path:
mount[2] .. checking /tmp -> C:\Users\User123\AppData\Local\Temp
44 13059 [main] dirname 16929 mount_info::conv_to_posix_path:
/c/Users/User123/bin = conv_to_posix_path (C:\Users\User123\bin)
```
could be cached with key
C:\Users\User123\bin
and value
/c/Users/User123/bin
at least for the current process (e.g. a bash script and it's
children) without risking any noticeable outdated cache issues
(probably even longer, however we want to keep it simple and don't
want to worry about cache invalidation too much)
More information about the Cygwin
mailing list