git-make-shallow: use stdin mode
PATCH 1/1 git-make-shallow: use stdin mode
when there are many refs to delete, using xargs to exec git can take a very long time. make this faster by only running git update-ref with stdin mode.
for a repo with over 34000 git tags this makes git-make-shallow finish in 2 seconds instead of 3 minutes for me.
--- bin/git-make-shallow | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
bin/git-make-shallow +2 -2
@@ -115,8 +115,8 @@ def filter_refs(refs): all_refs = get_all_refs() to_remove = set(all_refs) - set(refs) if to_remove: - check_output(['xargs', '-0', '-n', '1'] + git_cmd + ['update-ref', '-d', '--no-deref'], - input=''.join(l + '\0' for l in to_remove)) + check_output(git_cmd + ['update-ref', '--no-deref', '--stdin', '-z'], + input=''.join('delete ' + l + '\0\0' for l in to_remove) + 'commit\0') def follow_history_intersections(revisions, refs):
Signature · 1 line
2.34.1
Quoted 18 lines · Nick Owens via lists.openembedded.org
when there are many refs to delete, using xargs to exec git can take a very long time. make this faster by only running git update-ref with stdin mode.
for a repo with over 34000 git tags this makes git-make-shallow finish in 2 seconds instead of 3 minutes for me.
Signed-off-by Nick Owens <[email protected]>---
bin/git-make-shallow | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)bin/git-make-shallow +0
-0@@ -115,8 +115,8 @@ def filter_refs(refs): all_refs = get_all_refs() to_remove = set(all_refs) - set(refs)
Quoted 7 lines
if
to_remove:
- check_output(['xargs', '-0', '-n', '1'] +git_cmd+ ['update-ref', '-d', '--no-deref'], - input=''.join(l + '\0' for l into_remove))
+ check_output(git_cmd + ['update-ref', '--no-deref', '--stdin', '-z'],
+ input=''.join('delete ' + l + '\0\0' for l into_remove) + 'commit\0')
This sounded really good and it merged however we're seeing intermittent failures:
https://valkyrie.yoctoproject.org/#/builders/54/builds/725/steps/11/logs/stdio
https://valkyrie.yoctoproject.org/#/builders/23/builds/810/steps/11/logs/stdio
This appears like it might me python or git version specific, there is a deprecation warning in the log which I also wonder about...
Cheers,
Richard
right. i think this is because the transaction model was only introduced in git 2.27 whereas ubuntu focal (20.04) only has 2.25. and, i think i bungled the use of the transaction commands by not issuing 'start'. i think dropping commit should resolve it.
bitbake/bin/git-make-shallow +0 -1
@@ -113,8 +113,8 @@ def filter_refs(refs): all_refs = get_all_refs() to_remove = set(all_refs) - set(refs) if to_remove: - check_output(['xargs', '-0', '-n', '1', 'git', 'update-ref', '-d',
'--no-deref'],
- input=''.join(l + '\0' for l in to_remove))
+ check_output(['git', 'update-ref', '--no-deref', '--stdin', '-z'],
+ input=''.join('delete ' + l + '\0\0' for l into_remove))
def follow_history_intersections(revisions, refs):
Quoted 47 lines · Richard Purdie
Quoted 1 line · Nick Owens via lists.openembedded.org
when there are many refs to delete, using xargs to exec git can take a
very long
Quoted 15 lines
time. make this faster by only running git update-ref with stdin mode.
for a repo with over 34000 git tags this makes git-make-shallow finish in 2 seconds instead of 3 minutes for me.
Signed-off-by Nick Owens <[email protected]>--- bin/git-make-shallow | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)bin/git-make-shallow +0
-0bin/git-make-shallow def filter_refs(refs): · line 118
Quoted 4 lines
bin/git-make-shallow +0
-1@@ -115,8 +115,8 @@ def filter_refs(refs): all_refs = get_all_refs() to_remove = set(all_refs) - set(refs) if to_remove: - check_output(['xargs', '-0', '-n', '1'] + git_cmd +['update-ref', '-d', '--no-deref'],
bin/git-make-shallow def filter_refs(refs): · line 118
Quoted 2 lines
bin/git-make-shallow +1
-1- input=''.join(l + '\0' for l in to_remove)) + check_output(git_cmd + ['update-ref', '--no-deref', '--stdin','-z'],
bin/git-make-shallow def filter_refs(refs): · line 119
Quoted 1 line
bin/git-make-shallow +1
-0+ input=''.join('delete ' + l + '\0\0' for l in
to_remove) + 'commit\0')Quoted 2 lines
This sounded really good and it merged however we're seeing intermittent failures:
https://valkyrie.yoctoproject.org/#/builders/54/builds/725/steps/11/logs/stdio
https://valkyrie.yoctoproject.org/#/builders/23/builds/810/steps/11/logs/stdio
This appears like it might me python or git version specific, there is a deprecation warning in the log which I also wonder about...
Cheers,
Richard
Quoted 16 lines · Nick Owens
right. i think this is because the transaction model was only introduced in git 2.27 whereas ubuntu focal (20.04) only has 2.25. and, i think i bungled the use of the transaction commands by not issuing 'start'. i think dropping commit should resolve it.
bitbake/bin/git-make- renamed from bitbake/bin/git-make-shallow +0
-0shallow
indexd0532c5ab8..bead94a766100755bitbake/bin/git-make-shallow +0
-0@@ -113,8 +113,8 @@ def filter_refs(refs): all_refs = get_all_refs() to_remove = set(all_refs) - set(refs)if
to_remove:
- check_output(['xargs', '-0', '-n', '1', 'git', 'update-ref', '-d', '--no-deref'],
Quoted 8 lines
- input=''.join(l + '\0' for l in
to_remove))
+ check_output(['git', 'update-ref', '--no-deref', '--stdin', '-z'],
+ input=''.join('delete ' + l + '\0\0' for l into_remove))
deffollow_history_intersections(revisions, refs):
Thanks for the hint, I've turned this into a patch, sent and then merged it since this was breaking builds and there are enough other issues atm to worry about so I wanted to get it resolved! :)
I did test it on the failing 20.04 worker and it works there now.
Cheers,
Richard