[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: r1414123 - optimize iprops retrieval in libsvn_wc

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 12 Feb 2013 21:48:39 +0000 (GMT)

Paul Burba wrote:
> On Wed, Nov 28, 2012 at 2:25 PM, Julian Foad wrote:
>>> +/* Remove all prop name value pairs from PROP_HASH where the property
>>> +   name is not PROPNAME. */
>>> +static void
>>> +filter_unwanted_props(apr_hash_t *prop_hash,
>>> +                      const char * propname,
>>> +                      apr_pool_t *scratch_pool)
>>> +{
>>> +  apr_hash_index_t *hi;
>>> +
>>> +  for (hi = apr_hash_first(scratch_pool, prop_hash);
>>> +       hi;
>>> +       hi = apr_hash_next(hi))
>>> +    {
>>> +      const char *ipropname = svn__apr_hash_index_key(hi);
>>> +
>>> +      if (strcmp(ipropname, propname) != 0)
>>> +        apr_hash_set(prop_hash, ipropname, APR_HASH_KEY_STRING, NULL);
>>> +    }
>>
>> I suppose a much quicker way to select just the wanted key-value pair from
>> the hash is:
>>
>>    propval = hash_get(propname)
>>    hash_clear()
>
> (Julian - sorry for the tardy reply, I was cleaning out old TODOs
> today and found this)
>
> apr_hash_clear clears the hash by iterating over it just like we do above:
[...]
> I did a quick test: Set 10,000 properties on the root of a WC then
> ran 'svn pg some-prop some-subtree-path --show-inherited-props'.
> Average execution time over 5 runs was .052s for the existing code and
> .056s for your suggested change

IIRC I was thinking how many seconds quicker I could read the code as well as how many nanoseconds quicker I assumed hash_clear would be at run time.  That using the latter adds a microsecond [1] surprises me -- and I'm sure apr_hash_clear could be optimized if you care about such things -- but either way you'll have to run "svn pg" an awful lot of times now for it to add up to the hour I've spent looking at this.

> ...so I'll leave the code as is.

OK.

- Julian

[1] Linear extrapolation, assuming << 10 props on a typical directory.
Received on 2013-02-12 22:49:15 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.