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 7.3
dash 111,674 2.4
osh-native 118,863 12.4
osh-native-souffle 118,863 11.0

(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,479
bash 118,863 1,235
osh-native-souffle 118,863 440
osh-native 118,863 411
osh-cpython 118,863 10

Per-File Measurements

Time and Memory

shell label elapsed ms user ms sys ms max rss MB num lines filename
dash 2 0 2 2 2,698 Build.sh
bash 3 2 2 3 2,698 Build.sh
osh-native-souffle 7 5 3 8 2,698 Build.sh
osh-native 8 3 5 9 2,698 Build.sh
osh-cpython 327 302 26 21 2,698 Build.sh
dash 2 1 1 2 2,512 abuild
bash 4 3 1 3 2,512 abuild
osh-native-souffle 8 5 3 9 2,512 abuild
osh-native 9 4 5 9 2,512 abuild
osh-cpython 452 424 28 22 2,512 abuild
dash 9 8 1 2 20,489 configure
bash 18 16 2 4 20,489 configure
osh-native-souffle 42 34 8 21 20,489 configure
osh-native 44 36 8 21 20,489 configure
osh-cpython 2,131 2,085 45 44 20,489 configure
dash 23 23 0 2 69,779 configure-coreutils
bash 43 42 1 3 69,779 configure-coreutils
osh-native-souffle 157 139 18 50 69,779 configure-coreutils
osh-native 167 148 19 50 69,779 configure-coreutils
osh-cpython 6,264 6,193 70 91 69,779 configure-coreutils
bash 4 2 2 3 2,029 configure-helper.sh
osh-native-souffle 6 5 1 8 2,029 configure-helper.sh
osh-native 7 4 3 9 2,029 configure-helper.sh
osh-cpython 307 280 27 21 2,029 configure-helper.sh
dash 2 0 2 2 1,733 functions
bash 3 1 2 3 1,733 functions
osh-native-souffle 6 5 1 8 1,733 functions
osh-native 7 4 3 9 1,733 functions
osh-cpython 299 274 25 21 1,733 functions
dash 5 5 0 2 9,661 ltmain.sh
bash 9 9 0 4 9,661 ltmain.sh
osh-native-souffle 19 11 8 15 9,661 ltmain.sh
osh-native 21 15 6 15 9,661 ltmain.sh
osh-cpython 989 955 33 29 9,661 ltmain.sh
dash 1 0 1 2 1,679 t4014-format-patch.sh
bash 2 1 1 3 1,679 t4014-format-patch.sh
osh-native-souffle 4 2 2 7 1,679 t4014-format-patch.sh
osh-native 4 3 1 8 1,679 t4014-format-patch.sh
osh-cpython 118 94 24 19 1,679 t4014-format-patch.sh
dash 1 1 0 1 3,123 t9300-fast-import.sh
bash 3 2 1 3 3,123 t9300-fast-import.sh
osh-native 4 3 1 8 3,123 t9300-fast-import.sh
osh-native-souffle 5 4 1 8 3,123 t9300-fast-import.sh
osh-cpython 123 103 21 19 3,123 t9300-fast-import.sh
bash 8 7 1 3 5,160 test-cmd-util.sh
osh-native-souffle 16 11 5 12 5,160 test-cmd-util.sh
osh-native 18 15 3 13 5,160 test-cmd-util.sh
osh-cpython 898 870 29 28 5,160 test-cmd-util.sh

Instruction Counts

shell label irefs num lines filename
dash 6,683,550 2,698 Build.sh
bash 19,397,953 2,698 Build.sh
osh-native-souffle 31,029,250 2,698 Build.sh
osh-native 35,340,610 2,698 Build.sh
dash 7,343,949 2,512 abuild
bash 23,565,556 2,512 abuild
osh-native-souffle 36,277,978 2,512 abuild
osh-native 42,304,316 2,512 abuild
dash 55,988,249 20,489 configure
bash 166,228,288 20,489 configure
osh-native-souffle 230,513,243 20,489 configure
osh-native 262,822,445 20,489 configure
dash 161,007,687 69,779 configure-coreutils
bash 440,577,808 69,779 configure-coreutils
osh-native-souffle 753,048,760 69,779 configure-coreutils
osh-native 844,512,213 69,779 configure-coreutils
bash 22,785,798 2,029 configure-helper.sh
osh-native-souffle 24,674,422 2,029 configure-helper.sh
osh-native 28,502,993 2,029 configure-helper.sh
dash 4,811,021 1,733 functions
bash 15,304,971 1,733 functions
osh-native-souffle 23,049,641 1,733 functions
osh-native 26,864,446 1,733 functions
dash 24,901,464 9,661 ltmain.sh
bash 80,225,385 9,661 ltmain.sh
osh-native-souffle 91,935,766 9,661 ltmain.sh
osh-native 106,833,298 9,661 ltmain.sh
dash 3,292,797 1,679 t4014-format-patch.sh
osh-native-souffle 9,908,794 1,679 t4014-format-patch.sh
osh-native 10,889,474 1,679 t4014-format-patch.sh
bash 11,084,082 1,679 t4014-format-patch.sh
dash 4,583,408 3,123 t9300-fast-import.sh
osh-native-souffle 11,712,581 3,123 t9300-fast-import.sh
osh-native 12,893,926 3,123 t9300-fast-import.sh
bash 16,672,903 3,123 t9300-fast-import.sh
bash 73,188,823 5,160 test-cmd-util.sh
osh-native-souffle 92,390,809 5,160 test-cmd-util.sh
osh-native 106,871,194 5,160 test-cmd-util.sh

Shell and Host Details

shell label shell id
bash bash-fd7c50b3
dash dash-cea41b3e
osh-cpython osh-9ce1bd01
osh-native osh-f7800dad
osh-native-souffle osh-native-souffle-8fce1c43
host label host id
no-host no-host-2411472

Raw Data

filename
no-host.2025-05-01__16-43-09.cachegrind.tsv
no-host.2025-05-01__16-43-09.times.csv