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.6

(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,469.7 1,479.1
mksh 111,674 600.4 582.3
bash 118,863 326.6 338.4
oil-native 118,863 330.8 303.1
zsh 118,863 112.6 110.0
osh-cpython 118,863 6.4 6.5
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.7 2,698 Build.sh
13.7 1.0 3.3 3.1 3,123 t9300-fast-import.sh
32.0 NA NA 15.0 5,160 test-cmd-util.sh
18.2 1.8 6.1 9.2 9,661 ltmain.sh
17.4 1.9 6.4 9.3 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 91 138 159 6 0.8 1,679 t4014-format-patch.sh
broome 9 3 7 11 473 437 14 1.6 1,733 functions
broome 14 NA NA 19 479 472 15 1.1 2,029 configure-helper.sh
broome 14 4 10 17 684 671 16 1.1 2,512 abuild
broome 13 3 8 71 500 513 16 1.2 2,698 Build.sh
broome 11 2 5 103 151 153 7 0.6 3,123 t9300-fast-import.sh
broome 31 NA NA 27 1,463 1,396 28 0.9 5,160 test-cmd-util.sh
broome 34 9 21 40 1,690 1,545 33 1.0 9,661 ltmain.sh
broome 65 18 38 113 3,642 3,315 65 1.0 20,489 configure
broome 164 34 92 564 10,841 9,808 159 1.0 69,779 configure-coreutils
spring 8 2 4 90 148 156 6 0.7 1,679 t4014-format-patch.sh
spring 10 3 7 12 468 465 12 1.2 1,733 functions
spring 16 NA NA 21 478 460 12 0.7 2,029 configure-helper.sh
spring 15 4 10 15 702 670 19 1.2 2,512 abuild
spring 11 3 8 70 515 469 13 1.2 2,698 Build.sh
spring 13 2 5 100 170 163 7 0.6 3,123 t9300-fast-import.sh
spring 32 NA NA 26 1,413 1,317 31 1.0 5,160 test-cmd-util.sh
spring 34 9 24 37 1,698 1,534 37 1.1 9,661 ltmain.sh
spring 60 17 40 118 3,635 3,357 69 1.2 20,489 configure
spring 152 36 92 591 10,714 9,600 186 1.2 69,779 configure-coreutils

Parsing Rate (lines/ms)

host label bash dash mksh zsh osh-ovm osh-cpython oil-native num lines filename
broome 206.7 861.5 381.2 18.6 12.2 10.5 270.7 1,679 t4014-format-patch.sh
broome 196.8 644.2 232.6 154.1 3.7 4.0 123.4 1,733 functions
broome 146.2 NA NA 106.8 4.2 4.3 133.5 2,029 configure-helper.sh
broome 176.4 646.9 240.0 148.3 3.7 3.7 161.1 2,512 abuild
broome 204.1 861.7 350.3 38.0 5.4 5.3 170.4 2,698 Build.sh
broome 281.8 1,423.4 600.1 30.4 20.6 20.4 460.4 3,123 t9300-fast-import.sh
broome 164.2 NA NA 191.0 3.5 3.7 182.1 5,160 test-cmd-util.sh
broome 286.7 1,035.8 467.0 243.8 5.7 6.3 288.7 9,661 ltmain.sh
broome 313.3 1,114.5 537.4 181.4 5.6 6.2 314.8 20,489 configure
broome 425.1 2,027.0 758.8 123.7 6.4 7.1 439.5 69,779 configure-coreutils
spring 197.7 894.5 383.5 18.6 11.4 10.8 272.7 1,679 t4014-format-patch.sh
spring 179.7 647.9 242.1 139.9 3.7 3.7 146.5 1,733 functions
spring 128.6 NA NA 94.4 4.2 4.4 171.9 2,029 configure-helper.sh
spring 162.8 694.7 240.5 166.4 3.6 3.7 130.8 2,512 abuild
spring 246.6 864.2 344.6 38.5 5.2 5.7 204.6 2,698 Build.sh
spring 249.5 1,475.2 584.1 31.3 18.4 19.2 450.3 3,123 t9300-fast-import.sh
spring 159.6 NA NA 199.8 3.7 3.9 166.9 5,160 test-cmd-util.sh
spring 286.6 1,046.1 404.4 263.2 5.7 6.3 264.2 9,661 ltmain.sh
spring 341.6 1,209.6 506.3 173.2 5.6 6.1 296.2 20,489 configure
spring 457.7 1,942.5 756.4 118.1 6.5 7.3 374.4 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.5 1.7 1.7 3.9 14.3 17.9 5.6 1,679 t4014-format-patch.sh
broome 3.5 1.7 1.9 4.0 16.9 20.6 8.0 1,733 functions
broome 3.5 NA NA 4.0 17.5 21.4 8.3 2,029 configure-helper.sh
broome 3.4 1.7 1.9 4.1 19.1 23.2 9.8 2,512 abuild
broome 3.4 1.7 2.0 4.0 17.9 21.5 8.9 2,698 Build.sh
broome 3.5 1.7 1.9 4.1 14.8 18.1 6.0 3,123 t9300-fast-import.sh
broome 3.4 NA NA 4.0 27.6 33.3 17.6 5,160 test-cmd-util.sh
broome 4.4 2.1 3.1 4.5 29.6 35.0 19.8 9,661 ltmain.sh
broome 3.9 2.5 2.7 4.4 49.6 58.2 38.2 20,489 configure
broome 3.7 1.9 2.3 4.0 112.2 130.0 103.1 69,779 configure-coreutils
spring 3.4 1.7 1.8 4.0 14.1 17.6 5.6 1,679 t4014-format-patch.sh
spring 3.4 1.7 1.7 4.0 16.8 20.8 7.7 1,733 functions
spring 3.5 NA NA 4.0 17.5 21.5 8.2 2,029 configure-helper.sh
spring 3.4 1.8 1.8 4.1 19.0 23.3 9.8 2,512 abuild
spring 3.5 1.8 2.0 4.0 17.9 21.6 8.7 2,698 Build.sh
spring 3.5 1.8 1.8 4.1 14.6 18.3 5.8 3,123 t9300-fast-import.sh
spring 3.5 NA NA 4.1 27.5 33.1 17.7 5,160 test-cmd-util.sh
spring 4.4 2.2 3.1 4.6 29.4 35.0 20.0 9,661 ltmain.sh
spring 4.0 2.5 2.7 4.3 49.6 58.2 38.2 20,489 configure
spring 3.8 1.8 2.3 4.0 112.1 130.1 103.0 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-419ba42a
host label host id
broome broome-d80ab850
spring spring-d80ab850

Raw Data

filename
no-host.2021-11-18__14-19-40.cachegrind.tsv
broome.2021-11-18__19-21-59.times.csv
spring.2021-11-18__14-20-44.times.csv