To zrychleni o 70% je dost vagni informace. Kde a jak se to merilo, nikde nepisou.
Tak tedy jsem si nasel prislusny commit:
files: speed up reading by using getc_unlocked() instead of getc()
Unlike glibc, which in getc() locks the file only when it is needed,
FreeBSD and Bionic libc will always lock the file, causing a massive
slowdown, as the system has to create and destroy a mutex each time
getc() is called.
Uznavam, ze jsem C uz delsi dobu nepouzil a muze mi neco unikat, ale to je fakt normalni cist soubor bajt po bajtu pomoci getc() v cyklu while getc() != EOF?
OK, proč tam teda píšou, že to pro každý bajt zamyká? To asi není moc žádoucí.
Avoid that massive overhead by locking the file before starting to read
and unlocking it after reading is complete, and using getc_unlocked() to
read each byte. This makes reading on FreeBSD/macOS and Android anywhere
from 2 to 6 times faster, and on glibc roughly seventy percent faster.
První linux nainstaloval kolem roku 1994 a u něj zůstal. Později vystudoval fyziku a získal doktorát.