aboutsummaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-04-16 04:51:18 -0400
committerJunio C Hamano <gitster@pobox.com>2015-04-16 08:15:05 -0700
commit260d408e32363a9e76d0fea3056563d4fb51f29e (patch)
treea062f4480e0761fb1b5bbdbf49f08fc42e38f6a8 /strbuf.h
parent82912d1de86ae3d7f247bc3b16a81afd01aa31c7 (diff)
downloadgit-260d408e32363a9e76d0fea3056563d4fb51f29e.tar.gz
git-260d408e32363a9e76d0fea3056563d4fb51f29e.tar.xz
config: use getc_unlocked when reading from file
We read config files character-by-character from a stdio handle using fgetc(). This incurs significant locking overhead, even though we know that only one thread can possibly access the handle. We can speed this up by taking the lock ourselves, and then using getc_unlocked to read each character. On a silly pathological case: perl -le ' print "[core]"; print "key$_ = value$_" for (1..1000000) ' >input git config -f input core.key1 this dropped the time to run git-config from: real 0m0.263s user 0m0.260s sys 0m0.000s to: real 0m0.159s user 0m0.152s sys 0m0.004s for a savings of 39%. Most config files are not this big, but the savings should be proportional to the size of the file (i.e., we always save 39%, just of a much smaller number). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'strbuf.h')
0 files changed, 0 insertions, 0 deletions