В интернетах обсуждают очередное
сравнение скорости работы разных языков, на этот раз на примере user mode сетевых драйверов. С непреодолим как скорость света. Раст отстает, то ли из-за bounds checks, то ли из-за другого кодогенератора (LLVM vs. GCC). Неожиданно хорошо выступил C#, там есть value типы и слайсы/спаны, можно снизить нагрузку на GC до нуля практически, есть unsafe блоки и указатели. Близко к нему Go. Java отстала. Окамл получился быстрее Хаскеля. Но самый позорный результат из компилируемых языков - у Swift'a. И ведь не первый раз я вижу, что он так тормозит. Комментарии из их
статьи:
Swift increments a reference counter for each object passed into a function and decreases it when leaving the function. This is done for every single packet as they are wrapped in Swift-native wrappers for bounds checks. There is no good way to disable this behavior for the wrapper objects while maintaining an idiomatic API for applications using the driver. A total of
76% of the CPU time is spent incrementing and decrementing reference counters. This is the only language runtime evaluated here that incurs a large cost even for objects that are never free’d.
Вот вам и "RC быстрее GC".
Занятное про Хаскель:
Compiler (GHC 8.4.3) optimizations seem to do more harm than good in this workload. Increasing the optimization level in the default GHC backend from O1 to O2 reduces throughput by 11%. The data in the graph is based on the LLVM backend which is 3.5% faster than the default backend at O1. Enabling the threaded runtime in GHC decreases performance by 8% and causes the driver to lose packets even at loads below 1 Mpps due to regular GC pauses of several milliseconds.