From cf010a5035f783f6236901c79326434c324d8311 Mon Sep 17 00:00:00 2001 From: Ryan L McIntyre Date: Sun, 6 Nov 2016 17:04:53 -0500 Subject: [PATCH] Fixed background parallel processes to have a configurable maximum number --- .../gotta-patch-em-all-font-patcher!.sh | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/bin/scripts/gotta-patch-em-all-font-patcher!.sh b/bin/scripts/gotta-patch-em-all-font-patcher!.sh index 5b6a53b97..6fffe2a60 100755 --- a/bin/scripts/gotta-patch-em-all-font-patcher!.sh +++ b/bin/scripts/gotta-patch-em-all-font-patcher!.sh @@ -21,6 +21,7 @@ total_count=0 last_parent_dir="" unpatched_parent_dir="bin/scripts/../../src/unpatched-fonts" patched_parent_dir="patched-fonts" +max_parallel_process=64 if [ $# -eq 1 ] @@ -82,10 +83,11 @@ function patch_font { exit 1 } - fontforge -quiet -script ./font-patcher "$f" -q $powerline --complete --no-progressbars--outputdir "${patched_font_dir}complete/" 2>/dev/null & - fontforge -quiet -script ./font-patcher "$f" -q -s $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null & - fontforge -quiet -script ./font-patcher "$f" -q -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null & - fontforge -quiet -script ./font-patcher "$f" -q -s -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null & + + fontforge -quiet -script ./font-patcher "$f" -q $powerline --complete --no-progressbars--outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script ./font-patcher "$f" -q -s $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script ./font-patcher "$f" -q -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null + fontforge -quiet -script ./font-patcher "$f" -q -s -w $powerline --complete --no-progressbars --outputdir "${patched_font_dir}complete/" 2>/dev/null # wait for this group of background processes to finish to avoid forking too many processes # that can add up quickly with the number of combinations #wait @@ -142,16 +144,25 @@ function generate_readme { } >> "$combinations_filename" } -# Use for loop iterate through source fonts -# $f stores current value -for f in "${source_fonts[@]}" +# Iterate through source fonts +for i in "${!source_fonts[@]}" do - patch_font "$f" + patch_font "${source_fonts[$i]}" "$i" 2>/dev/null & + echo "complete_variation_count after bg proc is $complete_variation_count" # un-comment to test this script (patch 1 font) #break + # wait for this set of bg commands to finish: dont do too many at once! - #wait + # if we spawn a background process for each set of fonts it will + # end up using too many system resources + # however we want to run a certain number in parallel to decrease + # the amount of time patching all the fonts will take + # for now set a 'wait' for each X set of processes: + if [[ $(($i % $max_parallel_process)) == 0 ]]; + then + wait + fi done # wait for all bg commands to finish wait