OSH Parser Performance

We time $sh -n $file for various files under various shells, and repeat then run under cachegrind for stable metrics.

Source code: oil/benchmarks/osh-parser.sh

Raw files

Summary

Instructions Per Line (via cachegrind)

Lower numbers are generally better, but each shell recognizes a different language, and OSH uses a more thorough parsing algorithm. In thousands of "I refs".

shell label total lines thousand irefs per line
bash 118,863 15.1
dash 111,674 2.3
osh-native 118,863 13.1
osh-native-souffle 118,863 11.5

(zsh isn't measured because zsh -n unexpectedly forks.)

Average Parsing Rate, Measured on Two Machines (lines/ms)

Shell startup time is included in the elapsed time measurements, but long files are chosen to minimize its effect.

shell label total lines host no-host
dash 111,674 2,759
bash 118,863 710
osh-native-souffle 118,863 450
osh-native 118,863 413
osh-cpython 118,863 12

Per-File Measurements

Time and Memory

shell label elapsed ms user ms sys ms max rss MB num lines filename
dash 2 1 1 1 2,698 Build.sh
bash 4 3 1 3 2,698 Build.sh
osh-native-souffle 7 4 4 8 2,698 Build.sh
osh-native 8 5 3 8 2,698 Build.sh
osh-cpython 286 260 26 21 2,698 Build.sh
dash 2 1 1 1 2,512 abuild
bash 5 4 1 3 2,512 abuild
osh-native-souffle 9 6 3 8 2,512 abuild
osh-native 9 6 3 9 2,512 abuild
osh-cpython 378 353 26 22 2,512 abuild
dash 8 6 2 2 20,489 configure
bash 32 31 1 3 20,489 configure
osh-native-souffle 45 40 5 20 20,489 configure
osh-native 49 40 9 21 20,489 configure
osh-cpython 1,811 1,770 41 43 20,489 configure
dash 21 21 0 2 69,779 configure-coreutils
bash 78 75 3 3 69,779 configure-coreutils
osh-native-souffle 146 124 22 49 69,779 configure-coreutils
osh-native 159 134 25 50 69,779 configure-coreutils
osh-cpython 5,447 5,360 86 87 69,779 configure-coreutils
bash 5 4 1 3 2,029 configure-helper.sh
osh-native-souffle 6 4 3 8 2,029 configure-helper.sh
osh-native 7 6 2 8 2,029 configure-helper.sh
osh-cpython 274 248 26 21 2,029 configure-helper.sh
dash 1 0 1 1 1,733 functions
bash 4 3 1 3 1,733 functions
osh-native-souffle 6 4 2 8 1,733 functions
osh-native 7 6 1 8 1,733 functions
osh-cpython 262 246 16 21 1,733 functions
dash 4 3 1 2 9,661 ltmain.sh
bash 16 15 1 4 9,661 ltmain.sh
osh-native-souffle 19 13 6 15 9,661 ltmain.sh
osh-native 21 17 4 15 9,661 ltmain.sh
osh-cpython 867 845 22 29 9,661 ltmain.sh
dash 1 0 1 1 1,679 t4014-format-patch.sh
bash 3 3 0 3 1,679 t4014-format-patch.sh
osh-native-souffle 4 3 1 7 1,679 t4014-format-patch.sh
osh-native 4 2 2 7 1,679 t4014-format-patch.sh
osh-cpython 109 93 16 19 1,679 t4014-format-patch.sh
dash 1 0 1 1 3,123 t9300-fast-import.sh
osh-native-souffle 4 3 1 7 3,123 t9300-fast-import.sh
osh-native 4 2 3 8 3,123 t9300-fast-import.sh
bash 5 3 2 3 3,123 t9300-fast-import.sh
osh-cpython 109 91 18 19 3,123 t9300-fast-import.sh
bash 15 14 1 3 5,160 test-cmd-util.sh
osh-native-souffle 17 11 6 12 5,160 test-cmd-util.sh
osh-native 18 11 7 12 5,160 test-cmd-util.sh
osh-cpython 792 771 21 28 5,160 test-cmd-util.sh

Instruction Counts

shell label irefs num lines filename
dash 6,416,010 2,698 Build.sh
osh-native-souffle 32,957,588 2,698 Build.sh
bash 35,958,882 2,698 Build.sh
osh-native 37,595,209 2,698 Build.sh
dash 7,042,147 2,512 abuild
osh-native-souffle 38,793,938 2,512 abuild
bash 43,761,475 2,512 abuild
osh-native 45,316,639 2,512 abuild
dash 53,261,640 20,489 configure
osh-native-souffle 241,620,580 20,489 configure
osh-native 276,263,392 20,489 configure
bash 349,702,388 20,489 configure
dash 151,770,612 69,779 configure-coreutils
osh-native-souffle 782,404,525 69,779 configure-coreutils
osh-native 880,763,768 69,779 configure-coreutils
bash 886,197,417 69,779 configure-coreutils
osh-native-souffle 26,538,917 2,029 configure-helper.sh
osh-native 30,635,847 2,029 configure-helper.sh
bash 47,119,375 2,029 configure-helper.sh
dash 4,652,224 1,733 functions
osh-native-souffle 24,864,118 1,733 functions
bash 28,169,399 1,733 functions
osh-native 28,971,507 1,733 functions
dash 23,597,230 9,661 ltmain.sh
osh-native-souffle 97,419,926 9,661 ltmain.sh
osh-native 113,403,818 9,661 ltmain.sh
bash 172,930,991 9,661 ltmain.sh
dash 3,166,564 1,679 t4014-format-patch.sh
osh-native-souffle 10,811,280 1,679 t4014-format-patch.sh
osh-native 11,860,537 1,679 t4014-format-patch.sh
bash 25,314,918 1,679 t4014-format-patch.sh
dash 4,357,271 3,123 t9300-fast-import.sh
osh-native-souffle 12,675,110 3,123 t9300-fast-import.sh
osh-native 13,922,506 3,123 t9300-fast-import.sh
bash 41,138,083 3,123 t9300-fast-import.sh
osh-native-souffle 97,462,630 5,160 test-cmd-util.sh
osh-native 112,722,160 5,160 test-cmd-util.sh
bash 161,950,200 5,160 test-cmd-util.sh

Shell and Host Details

shell label shell id
bash bash-2a848bb2
dash dash-0ebcf347
osh-cpython osh-7a1bd5d6
osh-native osh-5506933a
osh-native-souffle osh-native-souffle-1a1d898a
host label host id
no-host no-host-e4839999

Raw Data

filename
no-host.2025-03-08__04-01-27.cachegrind.tsv
no-host.2025-03-08__04-01-27.times.csv