mbox series

[00/10] name-rev: improve memory usage

Message ID 084909f8-fefa-1fe0-b2ce-74eff47c4972@web.de (mailing list archive)
Headers show
Series name-rev: improve memory usage | expand

Message

René Scharfe Feb. 4, 2020, 9:12 p.m. UTC
This series seeks to get reduce the size of memory allocations, the
number of reallocations and the amount of leaks in git name-rev, to
improve its performance.  It starts with a few cleanups:

Martin Ågren (1):
  name-rev: rewrite create_or_update_name()

René Scharfe (9):
  name-rev: remove unused typedef
  name-rev: respect const qualifier
  name-rev: don't _peek() in create_or_update_name()

... then plugs a minor leak:

  name-rev: don't leak path copy in name_ref()

... and gets rid of a level of indirection in commit slab usage:

  name-rev: put struct rev_name into commit slab

The next two patches eliminate reallocations while building name strings
for parent commits, which can make a surprisingly big difference in some
cases:

  name-rev: factor out get_parent_name()
  name-rev: pre-size buffer in get_parent_name()

The next one avoids building names that are be discarded right away by
checking first if they are better than a possibly present other name
assigned earlier, which only provides a small speedup, but is the right
thing to do:

  name-rev: generate name strings only if they are better

And finally a tricky one whose commit message is a lot longer than its
diff, which adds a bit of overhead and which probably needs the most
reviewer attention to make sure it won't cause double frees:

  name-rev: release unused name strings

 builtin/name-rev.c | 133 ++++++++++++++++++++++++++-------------------
 1 file changed, 76 insertions(+), 57 deletions(-)

--
2.25.0

Comments

Derrick Stolee Feb. 5, 2020, 3:28 a.m. UTC | #1
On 2/4/2020 4:12 PM, René Scharfe wrote:
> This series seeks to get reduce the size of memory allocations, the
> number of reallocations and the amount of leaks in git name-rev, to
> improve its performance.

I am generally very happy with the performance benefits and think
this series is very well organized.

>   name-rev: don't leak path copy in name_ref()
>   name-rev: generate name strings only if they are better
>   name-rev: release unused name strings

I don't have the right context to understand these patches without
applying them and investigating the methods around the changes.
They intrigue me, though, so I plan to pick this up again tomorrow.

The rest of the changes look good.

Thanks,
-Stolee
Derrick Stolee Feb. 5, 2020, 3:20 p.m. UTC | #2
On 2/4/2020 10:28 PM, Derrick Stolee wrote:
> On 2/4/2020 4:12 PM, René Scharfe wrote:
>> This series seeks to get reduce the size of memory allocations, the
>> number of reallocations and the amount of leaks in git name-rev, to
>> improve its performance.
> 
> I am generally very happy with the performance benefits and think
> this series is very well organized.
> 
>>   name-rev: don't leak path copy in name_ref()
>>   name-rev: generate name strings only if they are better
>>   name-rev: release unused name strings
> 
> I don't have the right context to understand these patches without
> applying them and investigating the methods around the changes.
> They intrigue me, though, so I plan to pick this up again tomorrow.

After looking closely at these three, they LGTM.

Thanks,
-Stolee