You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fish killall autocompletion hangs if there are too many users reported by __fish_print_users (hundreds of thousands). It hangs on the initialization part, problem happens in __make_users_completions, which iterates over the list and performs expensive operations, I suspect it is id which takes 0.1s for each user (most likely because it is network call in my case).
Replacing __fish_print_users with the snippet below, which is essentially fallback behavior of default __fish_print_users plus operator username at the start significantly reduces the number of entries thus making killall autocompletion work again. But this is definitely not a proper solution, just a workaround.
function__fish_print_users --description "Print a list of local users"echo$USER
string match -v -r '^\w*#'< /etc/passwd | cut -d : -f 1
end
Since __fish_print_users itself works fast one of my ideas would be to check size of the list returned before iterating over it and fallback to "local" version from passwd if it is too big. Draft is below:
function__make_users_completionsset -l users (__fish_print_users)
set -l users_size (count $users)
if math "$users_size>$__fish_killall_max_users"set users (__fish_print_local_users)
end
foruserin$usersset -l uid (id -u $user)
# GNU doesn't support UID
killall --version > /dev/null ^ /dev/null; and set -el uid
complete -c killall -s u -x -a "$user$uid" -d "Match only processes belonging to $user"
end
end
The text was updated successfully, but these errors were encountered:
That completion script has a number of inefficiencies. For example, the repeated killall --version invocations should be done exactly once to set a variable that is then checked. I also don't see the point of looking up the UID for a given user name and letting the user choose either the name or ID. Just give the user a list of valid user names and let killall convert it to a UID.
And why is it creating a distinct completion for each user? It should instead just do
complete -c killall -s -u -l user -x -a "(__fish_complete_users)"
krader1961
changed the title
killall hangs if there are too many users in the system
killall command completion is way too slow if there are many user accounts
May 3, 2017
Fish killall autocompletion hangs if there are too many users reported by
__fish_print_users
(hundreds of thousands). It hangs on the initialization part, problem happens in __make_users_completions, which iterates over the list and performs expensive operations, I suspect it isid
which takes 0.1s for each user (most likely because it is network call in my case).Replacing
__fish_print_users
with the snippet below, which is essentially fallback behavior of default__fish_print_users
plus operator username at the start significantly reduces the number of entries thus making killall autocompletion work again. But this is definitely not a proper solution, just a workaround.Since
__fish_print_users
itself works fast one of my ideas would be to check size of the list returned before iterating over it and fallback to "local" version from passwd if it is too big. Draft is below:The text was updated successfully, but these errors were encountered: