Using pam authentication with Mercurial over HTTP is very slow.
I think this is caused by the fact that mercurial always tries to perform an operation anonymously and after that, tries authentication based on username.
A simple 'hg pull', results in 4 calls to the pam module (slow) to authenticate user '' (empty string) + 4 normal calls with username. The empty string also skips the cache in auth_pam.py. And the cache TTL is only 4 seconds, therefore the cache is also invalid most of the time for the valid calls with username. I think the pam module should not call pam for an empty user?
FIX: At the beginning of the auth(...) function in auth_pam.py add the following:
# abort if empty username if not username: return None
Result of 'time hg pull'