name-rev: put struct rev_name into commit slab
commitf13ca7cef51cc709c645f9da97f09a150bdb2cac
authorRené Scharfe <l.s.r@web.de>
Tue, 4 Feb 2020 21:22:36 +0000 (4 22:22 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2020 18:24:15 +0000 (5 10:24 -0800)
tree663eb5711a834524d422cceee285d9afca1795e9
parentd689d6d82fae2f4f948bf1c232cb1fe158e3f319
name-rev: put struct rev_name into commit slab

The commit slab commit_rev_name contains a pointer to a struct rev_name,
and the actual struct is allocated separatly.  Avoid that allocation and
pointer indirection by storing the full struct in the commit slab.  Use
the tip_name member pointer to determine if the returned struct is
initialized.

Performance in the Linux repository measured with hyperfine before:

Benchmark #1: ./git -C ../linux/ name-rev --all
  Time (mean ± σ):     953.5 ms ±   6.3 ms    [User: 901.2 ms, System: 52.1 ms]
  Range (min … max):   945.2 ms … 968.5 ms    10 runs

... and with this patch:

Benchmark #1: ./git -C ../linux/ name-rev --all
  Time (mean ± σ):     851.0 ms ±   3.1 ms    [User: 807.4 ms, System: 43.6 ms]
  Range (min … max):   846.7 ms … 857.0 ms    10 runs

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/name-rev.c