The wtmp helper code examines /var/log/wtmp to determine which
users log in the most frequently.
That code calls getpwnam() once for every entry in /var/log/wtmp.
This is very inefficient, since getpwnam() can be quite slow, and
/var/log/wtmp will often have the same users repeated over and
Also, we don't actually use the result for anything other than verifying
the existence of the user! And we already verify the existence of
the user later later in the code in a more efficient way (by finding
the user in the users hashtable).
This commit just drops the unnecessary getpwnam() call.
Created attachment 139099 [details] [review]
wtmp-helper: don't call getpwnam()
Tested-by: Paul Menzel <email@example.com>
… with `/var/log/tmp` with size of 20 MB, which are roughly 25,000 lines in the output of `last`.
Attachment 139099 [details] pushed as 081a2b7 - wtmp-helper: don't call getpwnam()