git-commit-vandalism/t/helper
Jeff Hostetler 8b604d1951 hashmap: add API to disable item counting when threaded
This is to address concerns raised by ThreadSanitizer on the mailing list
about threaded unprotected R/W access to map.size with my previous "disallow
rehash" change (0607e10009).

See:
https://public-inbox.org/git/adb37b70139fd1e2bac18bfd22c8b96683ae18eb.1502780344.git.martin.agren@gmail.com/

Add API to hashmap to disable item counting and thus automatic rehashing.
Also include API to later re-enable them.

When item counting is disabled, the map.size field is invalid.  So to
prevent accidents, the field has been renamed and an accessor function
hashmap_get_size() has been added.  All direct references to this
field have been been updated.  And the name of the field changed
to map.private_size to communicate this.

Here is the relevant output from ThreadSanitizer showing the problem:

WARNING: ThreadSanitizer: data race (pid=10554)
  Read of size 4 at 0x00000082d488 by thread T2 (mutexes: write M16):
     hashmap_add hashmap.c:209
     hash_dir_entry_with_parent_and_prefix name-hash.c:302
     handle_range_dir name-hash.c:347
     handle_range_1 name-hash.c:415
     lazy_dir_thread_proc name-hash.c:471
     <null> <null>

  Previous write of size 4 at 0x00000082d488 by thread T1 (mutexes: write M31):
     hashmap_add hashmap.c:209
     hash_dir_entry_with_parent_and_prefix name-hash.c:302
     handle_range_dir name-hash.c:347
     handle_range_1 name-hash.c:415
     handle_range_dir name-hash.c:380
     handle_range_1 name-hash.c:415
     lazy_dir_thread_proc name-hash.c:471
     <null> <null>

Martin gives instructions for running TSan on test t3008 in this post:
https://public-inbox.org/git/CAN0heSoJDL9pWELD6ciLTmWf-a=oyxe4EXXOmCKvsG5MSuzxsA@mail.gmail.com/

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-07 09:42:02 +09:00
..
.gitignore
test-chmtime.c
test-config.c
test-ctype.c
test-date.c
test-delta.c
test-dump-cache-tree.c
test-dump-split-index.c
test-dump-untracked-cache.c
test-fake-ssh.c
test-genrandom.c
test-hashmap.c hashmap: add API to disable item counting when threaded 2017-09-07 09:42:02 +09:00
test-index-version.c
test-lazy-init-name-hash.c name-hash: add test-lazy-init-name-hash 2017-03-24 11:00:03 -07:00
test-line-buffer.c
test-match-trees.c
test-mergesort.c
test-mktemp.c
test-online-cpus.c
test-parse-options.c
test-path-utils.c test-path-utils: handle const parameter of basename and dirname 2017-08-07 10:50:08 -07:00
test-prio-queue.c
test-read-cache.c
test-ref-store.c
test-regex.c
test-revision-walking.c
test-run-command.c
test-scrap-cache-tree.c
test-sha1-array.c
test-sha1.c
test-sha1.sh
test-sigchain.c
test-strcmp-offset.c
test-string-list.c
test-submodule-config.c submodule: remove gitmodules_config 2017-08-03 13:11:02 -07:00
test-subprocess.c
test-svn-fe.c
test-urlmatch-normalization.c
test-wildmatch.c
test-write-cache.c perf: add test for writing the index 2017-08-21 15:56:53 -07:00