I tried this on OpenBSD, and ruby 2.7 and 3.0 were faster than ruby 2.4 (all of these use libyaml 0.2.2):
/usr/local/bin/ruby27: 0.1 i/s
/usr/local/bin/ruby30: 0.1 i/s - 1.00x slower
/usr/local/bin/ruby24: 0.0 i/s - 1.46x slower
/usr/local/bin/ruby26: 0.0 i/s - 1.83x slower
/usr/local/bin/ruby25: 0.0 i/s - 1.98x slower
I also tested on Windows, where performance on ruby 3.0 and 2.7 is not as good as 2.4, but still much better than 2.5 and 2.6 (these use whatever libyaml is embedded in RubyInstaller):
C:\\ruby24-x64\\bin\\ruby: 0.1 i/s
C:\\ruby30-x64\\bin\\ruby: 0.0 i/s - 1.26x slower
C:\\ruby27-x64\\bin\\ruby: 0.0 i/s - 1.30x slower
C:\\ruby26-x64\\bin\\ruby: 0.0 i/s - 2.06x slower
C:\\ruby25-x64\\bin\\ruby: 0.0 i/s - 2.13x slower
It's likely the decrease in performance in Windows on ruby 2.7 and 3.0 is due to different versions of libyaml:
D:\>c:\Ruby30-x64\bin\ruby -r yaml -e "p Psych::LIBYAML_VERSION"
"0.2.5"
D:\>c:\Ruby27-x64\bin\ruby -r yaml -e "p Psych::LIBYAML_VERSION"
"0.2.2"
D:\>c:\Ruby26-x64\bin\ruby -r yaml -e "p Psych::LIBYAML_VERSION"
"0.2.1"
D:\>c:\Ruby25-x64\bin\ruby -r yaml -e "p Psych::LIBYAML_VERSION"
"0.1.6"
D:\>c:\Ruby24-x64\bin\ruby -r yaml -e "p Psych::LIBYAML_VERSION"
"0.1.6"
There no longer appears to be a massive slowdown, and it appears that for the same libyaml version, ruby 2.7 and 3.0 are faster, so I'm going to close this.