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,479.5 1,540.8
mksh 111,674 599.2 581.6
bash 118,863 351.5 351.1
oil-native 118,863 311.4 318.0
zsh 118,863 111.9 114.6
osh-cpython 118,863 6.7 6.8
osh-ovm 118,863 5.9 6.1

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.4 1,733 functions
23.7 NA NA 12.2 2,029 configure-helper.sh
17.8 2.1 8.9 14.0 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 14.9 5,160 test-cmd-util.sh
18.2 1.8 6.1 9.2 9,661 ltmain.sh
17.3 1.9 6.4 9.3 20,489 configure
12.9 1.5 5.4 7.7 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 147 153 6 0.7 1,679 t4014-format-patch.sh
broome 10 3 7 13 466 435 15 1.5 1,733 functions
broome 15 NA NA 20 490 444 15 1.0 2,029 configure-helper.sh
broome 12 3 10 15 718 660 16 1.3 2,512 abuild
broome 12 3 7 71 480 446 14 1.1 2,698 Build.sh
broome 12 2 5 100 161 169 7 0.6 3,123 t9300-fast-import.sh
broome 31 NA NA 28 1,432 1,319 31 1.0 5,160 test-cmd-util.sh
broome 34 10 23 39 1,695 1,533 33 1.0 9,661 ltmain.sh
broome 61 17 36 117 3,620 3,211 68 1.1 20,489 configure
broome 143 35 93 571 10,808 9,415 177 1.2 69,779 configure-coreutils
spring 9 2 4 85 147 157 6 0.7 1,679 t4014-format-patch.sh
spring 10 3 7 13 441 437 11 1.1 1,733 functions
spring 12 NA NA 19 461 433 14 1.2 2,029 configure-helper.sh
spring 14 3 11 17 663 625 18 1.3 2,512 abuild
spring 13 3 8 71 492 464 15 1.2 2,698 Build.sh
spring 11 2 6 98 144 164 7 0.7 3,123 t9300-fast-import.sh
spring 31 NA NA 26 1,375 1,298 30 1.0 5,160 test-cmd-util.sh
spring 37 9 23 39 1,701 1,583 34 0.9 9,661 ltmain.sh
spring 61 17 39 113 3,618 3,172 66 1.1 20,489 configure
spring 141 33 94 555 10,481 9,238 172 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 199.8 786.0 414.1 18.8 11.4 10.9 268.9 1,679 t4014-format-patch.sh
broome 173.0 649.3 239.4 138.0 3.7 4.0 118.4 1,733 functions
broome 139.0 NA NA 100.2 4.1 4.6 133.3 2,029 configure-helper.sh
broome 206.8 719.6 257.4 172.0 3.5 3.8 153.5 2,512 abuild
broome 217.6 846.6 364.1 38.1 5.6 6.0 190.6 2,698 Build.sh
broome 256.7 1,453.2 601.3 31.4 19.4 18.5 431.1 3,123 t9300-fast-import.sh
broome 168.6 NA NA 182.1 3.6 3.9 168.7 5,160 test-cmd-util.sh
broome 284.1 983.6 413.4 249.9 5.7 6.3 295.8 9,661 ltmain.sh
broome 334.5 1,199.4 563.5 174.7 5.7 6.4 302.7 20,489 configure
broome 489.4 1,996.9 750.4 122.2 6.5 7.4 394.4 69,779 configure-coreutils
spring 194.8 886.0 409.1 19.7 11.4 10.7 274.5 1,679 t4014-format-patch.sh
spring 165.9 650.0 241.7 132.4 3.9 4.0 151.0 1,733 functions
spring 169.5 NA NA 104.1 4.4 4.7 144.1 2,029 configure-helper.sh
spring 178.5 728.3 233.0 152.0 3.8 4.0 138.0 2,512 abuild
spring 214.9 841.3 325.7 38.1 5.5 5.8 176.2 2,698 Build.sh
spring 287.3 1,451.2 556.0 31.9 21.7 19.0 441.2 3,123 t9300-fast-import.sh
spring 166.4 NA NA 196.5 3.8 4.0 172.8 5,160 test-cmd-util.sh
spring 262.4 1,052.6 413.7 244.9 5.7 6.1 285.8 9,661 ltmain.sh
spring 336.8 1,208.8 527.7 181.3 5.7 6.5 311.9 20,489 configure
spring 493.7 2,115.7 743.4 125.6 6.7 7.6 405.3 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.3 1.7 1.9 4.1 14.2 17.8 5.5 1,679 t4014-format-patch.sh
broome 3.4 1.7 1.7 4.1 16.8 20.7 8.0 1,733 functions
broome 3.4 NA NA 4.1 17.4 21.3 8.3 2,029 configure-helper.sh
broome 3.3 1.7 1.9 4.1 19.1 23.1 9.8 2,512 abuild
broome 3.4 1.7 2.0 4.1 17.9 21.7 8.6 2,698 Build.sh
broome 3.5 1.7 1.9 4.0 14.7 18.2 5.8 3,123 t9300-fast-import.sh
broome 3.6 NA NA 3.9 27.9 33.3 17.6 5,160 test-cmd-util.sh
broome 4.5 2.1 3.1 4.5 29.5 35.1 19.8 9,661 ltmain.sh
broome 4.0 2.6 2.7 4.5 49.8 58.2 38.3 20,489 configure
broome 3.7 1.8 2.2 4.0 112.3 130.1 103.0 69,779 configure-coreutils
spring 3.5 1.7 1.9 4.0 14.2 17.7 5.5 1,679 t4014-format-patch.sh
spring 3.4 1.7 1.9 4.1 16.9 20.9 7.8 1,733 functions
spring 3.4 NA NA 4.1 17.4 21.2 8.2 2,029 configure-helper.sh
spring 3.4 1.8 1.9 3.9 19.0 23.2 9.9 2,512 abuild
spring 3.4 1.7 2.0 4.1 17.8 21.7 8.6 2,698 Build.sh
spring 3.4 1.7 1.9 4.1 14.3 18.1 6.0 3,123 t9300-fast-import.sh
spring 3.6 NA NA 4.1 28.0 33.2 17.5 5,160 test-cmd-util.sh
spring 4.3 2.1 3.0 4.6 29.6 35.0 19.9 9,661 ltmain.sh
spring 4.0 2.5 2.7 4.3 49.8 58.2 38.1 20,489 configure
spring 3.8 1.8 2.3 4.0 112.3 130.1 103.1 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-bbc52eb6
host label host id
broome broome-d80ab850
spring spring-d80ab850

Raw Data

filename
no-host.2021-09-16__13-41-08.cachegrind.tsv
broome.2021-09-16__18-02-44.times.csv
spring.2021-09-16__13-42-16.times.csv