Bug 1495 - sftp performance of "ls -l" cmd is slow on network-authed servers
Summary: sftp performance of "ls -l" cmd is slow on network-authed servers
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: -current
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_5_4
  Show dependency treegraph
 
Reported: 2008-07-30 06:49 AEST by mark smith
Modified: 2010-03-26 10:50 AEDT (History)
3 users (show)

See Also:


Attachments
sftp-namecache.patch (3.41 KB, text/plain)
2010-01-14 16:24 AEDT, Darren Tucker
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description mark smith 2008-07-30 06:49:57 AEST
when sftp client connects to sftp-server and does "ls -l" command on a large directory (many files), performance is unacceptably slow when the sftp-server node used ldap/kerberos/NIS/...(etc) to look up EVERY uid/gid on every file.

a simple fix is to cache/buffer the uid/gid of the previous file from the stat()/fstat() & chk to see if they have changed before issuing the lookup of the same uid/gid (ergo inhibiting a wait-for-network to get info that we already have)

same issue true for v4.1p1 through current.
Comment 1 Damien Miller 2009-01-21 21:27:35 AEDT
Isn't this the role of nscd (or similar)?
Comment 2 Michael Rhyner 2009-07-06 18:52:28 AEST
nscd helped on this issue, issuing e.g. 'ls -l' is now as fast as expected. Cache times within nscd.conf could be quite small, e.g. between 20 and 60 seconds, it you want to avoid that services rely on outdated information.
Comment 3 Darren Tucker 2010-01-14 16:24:08 AEDT
Created attachment 1779 [details]
sftp-namecache.patch

Add a small LRU to cache user and group names.
Comment 4 Darren Tucker 2010-01-15 10:46:31 AEDT
deraadt points out that similar functions (user_from_uid and group_from_gid) exist in OpenBSD's libc ( both keep a 64-entry hash table as a cache)  We have just commited a change with that.

We'll add these functions to the compat library for any platform that doesn't have them.
Comment 5 Darren Tucker 2010-03-26 10:50:53 AEDT
With the release of 5.4p1, this bug is now considered closed.