pam authentication very slow + fix

Issue #180 resolved
Silas De Munck created an issue

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'

*Before: 17s

*After: 3s

Comments (5)

  1. Mads Kiilerich

    Thanks!

    But how come reducing the number of pam auth calls by a factor 2 could reduce the time by a factor 5?

  2. Silas De Munck reporter

    I think this is because of the cache TTL, this is by default 4 seconds. The numerous calls seem to take longer than that, invalidating the cache, hence even more pam calls?

  3. Log in to comment