On 4/5/2021 10:01 AM, ZheNing Hu via GitGitGadget wrote: > From: ZheNing Hu <adlternative@xxxxxxxxx> > > When we use `git for-each-ref`, every ref will call > `show_ref_array_item()` and allocate its own final strbuf > and error strbuf. Instead, we can provide two single strbuf: > final_buf and error_buf that get reused for each output. s/two single strbuf/two buffers/ > When run it 100 times: > > $ git for-each-ref > > on git.git : > > 3.19s user > 3.88s system > 35% cpu > 20.199 total > > to: > > 2.89s user > 4.00s system > 34% cpu > 19.741 total > > The performance has been slightly improved. This is a nice amount of time! Perhaps simplify the presentation: The performance for 'git for-each-ref' on the Git repository itself with X references changes from 3.2 seconds to 2.9 seconds. > Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx> > --- > [GSOC] ref-filter: use single strbuf for all output > > This patch learned Jeff King's optimization measures in git > cat-file(79ed0a5): using a single strbuf for all objects output Instead > of allocating a large number of small strbuf for every object. This part of the cover letter could be put into the commit message itself. Use the correct formatting, though: This approach is similar to the one used by 79ed0a5 (cat-file: use a single strbuf for all output, 2018-08-14) to speed up the cat-file builtin. I found the code change to be correct. Thanks! -Stolee