OSH Parser Performance

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

Summary

Instructions Per Line (via cachegrind)

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

shell label total lines thousand irefs per line
bash 118,863 15.3
dash 111,674 1.6
mksh 111,674 5.7
oil-native 118,863 8.7

(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 broome host spring
dash 111,674 1,468.6 1,483.1
mksh 111,674 595.4 587.9
bash 118,863 352.7 370.4
oil-native 118,863 311.1 318.0
zsh 118,863 111.7 111.8
osh-cpython 118,863 6.6 6.6
osh-ovm 118,863 5.9 6.0

Breakdown By File

Instructions Per Line (in thousands)

bash dash mksh oil-native num lines filename
15.6 1.3 4.4 4.8 1,679 t4014-format-patch.sh
16.7 2.1 8.4 13.5 1,733 functions
23.7 NA NA 12.2 2,029 configure-helper.sh
17.8 2.1 8.9 14.1 2,512 abuild
13.6 1.8 5.9 9.8 2,698 Build.sh
13.7 1.0 3.3 3.1 3,123 t9300-fast-import.sh
32.0 NA NA 15.1 5,160 test-cmd-util.sh
18.2 1.8 6.1 9.3 9,661 ltmain.sh
17.4 1.9 6.4 9.4 20,489 configure
12.9 1.5 5.4 7.8 69,779 configure-coreutils

Elasped Time (milliseconds)

host label bash dash mksh zsh osh-ovm osh-cpython oil-native osh to bash ratio num lines filename
broome 8 2 4 89 131 152 6 0.8 1,679 t4014-format-patch.sh
broome 10 3 8 13 468 437 12 1.2 1,733 functions
broome 15 NA NA 20 484 457 15 1.0 2,029 configure-helper.sh
broome 13 4 9 18 716 628 18 1.4 2,512 abuild
broome 12 3 8 73 511 449 13 1.0 2,698 Build.sh
broome 12 2 6 105 174 145 7 0.6 3,123 t9300-fast-import.sh
broome 30 NA NA 25 1,500 1,281 32 1.1 5,160 test-cmd-util.sh
broome 34 9 23 41 1,708 1,502 34 1.0 9,661 ltmain.sh
broome 62 17 37 115 3,708 3,347 68 1.1 20,489 configure
broome 140 35 93 564 10,872 9,693 177 1.3 69,779 configure-coreutils
spring 9 2 4 94 135 154 6 0.7 1,679 t4014-format-patch.sh
spring 11 3 7 11 466 451 12 1.1 1,733 functions
spring 14 NA NA 20 506 450 15 1.0 2,029 configure-helper.sh
spring 15 3 10 18 679 614 18 1.2 2,512 abuild
spring 12 3 8 70 493 469 12 1.0 2,698 Build.sh
spring 12 2 6 99 154 162 7 0.6 3,123 t9300-fast-import.sh
spring 31 NA NA 28 1,470 1,308 30 1.0 5,160 test-cmd-util.sh
spring 32 9 23 39 1,669 1,553 30 0.9 9,661 ltmain.sh
spring 60 17 38 115 3,633 3,265 66 1.1 20,489 configure
spring 125 35 94 569 10,658 9,625 177 1.4 69,779 configure-coreutils

Parsing Rate (lines/ms)

host label bash dash mksh zsh osh-ovm osh-cpython oil-native num lines filename
broome 200.4 802.6 409.8 18.8 12.8 11.0 266.1 1,679 t4014-format-patch.sh
broome 172.0 650.0 227.5 135.5 3.7 4.0 148.6 1,733 functions
broome 138.5 NA NA 99.6 4.2 4.4 132.1 2,029 configure-helper.sh
broome 191.5 686.7 280.8 143.2 3.5 4.0 138.5 2,512 abuild
broome 220.0 865.9 322.1 36.7 5.3 6.0 214.2 2,698 Build.sh
broome 250.3 1,442.5 556.6 29.8 18.0 21.6 432.7 3,123 t9300-fast-import.sh
broome 173.9 NA NA 204.6 3.4 4.0 163.3 5,160 test-cmd-util.sh
broome 288.3 1,028.1 428.5 236.4 5.7 6.4 283.9 9,661 ltmain.sh
broome 328.5 1,173.3 552.1 177.6 5.5 6.1 302.1 20,489 configure
broome 496.8 1,966.4 748.2 123.6 6.4 7.2 393.3 69,779 configure-coreutils
spring 193.6 861.0 407.0 17.9 12.5 10.9 294.0 1,679 t4014-format-patch.sh
spring 164.4 632.3 239.2 155.4 3.7 3.8 145.0 1,733 functions
spring 142.1 NA NA 102.1 4.0 4.5 135.8 2,029 configure-helper.sh
spring 168.9 722.3 239.9 141.3 3.7 4.1 136.2 2,512 abuild
spring 229.1 854.1 345.1 38.3 5.5 5.8 229.8 2,698 Build.sh
spring 251.2 1,441.2 564.6 31.4 20.3 19.3 429.5 3,123 t9300-fast-import.sh
spring 167.2 NA NA 186.9 3.5 3.9 169.4 5,160 test-cmd-util.sh
spring 297.4 1,032.6 423.8 247.6 5.8 6.2 318.0 9,661 ltmain.sh
spring 340.5 1,177.7 542.3 177.9 5.6 6.3 309.9 20,489 configure
spring 559.1 1,990.7 740.9 122.6 6.5 7.2 394.8 69,779 configure-coreutils

Memory Usage (Max Resident Set Size in MB)

Again, Oil uses a different algorithm (and language) than POSIX shells. It builds an AST in memory rather than just validating the code line-by-line.

host label bash dash mksh zsh osh-ovm osh-cpython oil-native num lines filename
broome 3.4 1.7 1.8 4.1 14.4 17.7 5.5 1,679 t4014-format-patch.sh
broome 3.4 1.7 2.0 3.9 17.1 20.9 7.9 1,733 functions
broome 3.4 NA NA 3.9 17.7 21.4 8.3 2,029 configure-helper.sh
broome 3.4 1.8 2.0 4.0 19.1 23.5 9.8 2,512 abuild
broome 3.4 1.7 2.0 4.0 17.7 21.8 8.6 2,698 Build.sh
broome 3.5 1.7 1.9 4.0 14.6 18.1 5.9 3,123 t9300-fast-import.sh
broome 3.6 NA NA 4.0 27.9 33.2 17.8 5,160 test-cmd-util.sh
broome 4.3 2.2 2.9 4.5 29.4 35.2 19.8 9,661 ltmain.sh
broome 4.1 2.5 2.6 4.4 49.7 58.6 38.2 20,489 configure
broome 3.7 1.8 2.3 4.2 112.5 130.4 103.2 69,779 configure-coreutils
spring 3.5 1.7 1.8 4.1 14.4 17.8 5.4 1,679 t4014-format-patch.sh
spring 3.5 1.8 1.9 4.1 17.1 20.9 7.8 1,733 functions
spring 3.3 NA NA 4.1 17.6 21.5 8.4 2,029 configure-helper.sh
spring 3.4 1.7 1.8 4.0 19.1 23.3 9.9 2,512 abuild
spring 3.5 1.8 2.0 4.1 17.8 21.8 8.8 2,698 Build.sh
spring 3.4 1.7 1.8 3.9 14.7 18.2 5.8 3,123 t9300-fast-import.sh
spring 3.6 NA NA 4.1 27.8 33.2 17.7 5,160 test-cmd-util.sh
spring 4.3 2.2 3.0 4.5 29.4 35.3 19.8 9,661 ltmain.sh
spring 3.9 2.5 2.7 4.4 49.7 58.3 38.2 20,489 configure
spring 3.8 1.9 2.3 4.0 112.4 130.4 103.2 69,779 configure-coreutils

Shell and Host Details

shell label shell id
bash bash-9af8f89f
dash dash-9ff48631
mksh mksh-e3755400
oil-native osh_eval.opt.stripped-d7f10784
host label host id
broome broome-d80ab850
spring spring-d80ab850

Raw Data

filename
no-host.2021-12-29__22-15-22.cachegrind.tsv
broome.2021-12-30__03-12-27.times.csv
spring.2021-12-29__22-16-29.times.csv