]> git.ipfire.org Git - thirdparty/git.git/commit - name-hash.c
name-hash: perf improvement for lazy_init_name_hash
authorJeff Hostetler <jeffhost@microsoft.com>
Thu, 23 Mar 2017 13:47:03 +0000 (13:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Mar 2017 18:00:03 +0000 (11:00 -0700)
commit846df809bc671d6487fa2be7550e3ed2b62e62f9
treebe5bef35e037d77e35ff690250b670a1d4705258
parent4f4458aafa809e184358256e35fd90c227dba81d
name-hash: perf improvement for lazy_init_name_hash

Improve performance of lazy_init_name_hash() when
ignore_case is set.  Teach name-hash to build the
istate.name_hash and istate.dir_hash simultaneously
using a forward-diving technique on the pathname
of the index_entry, rather than adding name_hash
entries and then searching backwards in the pathname
for parent directories.

This borrows algorithm ideas from clear_ce_flags_{1,dir}.

Multiple threads are used with the new algorithm to
speed hashmap construction.

This new code path is only used when threads are present
(a compiler settings) and when the index is large enough
to warrant the pthread complexity.

The code in clear_ce_flags_dir() uses a linear search to
find the adjacent index entries with the same prefix; a
binary search is used here handle_range_dir() to further
speed things up.

The size of LAZY_THREAD_COST was determined from rough
analysis using:
    t/helper/test-lazy-init-name-hash --analyze

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
name-hash.c