3 ms·
The zero cost abstraction remarks remind me of this code that I recently wrote: https://github.com/openzfs/zfs/commit/677c6f8457943fe5b56d7aa8807010a104563e4a
by ryao 3y ago
The zero cost abstraction remarks remind me of this code that I recently wrote:
https://github.com/openzfs/zfs/commit/677c6f8457943fe5b56d7aa8807010a104563e4a https://github.com/openzfs/zfs/commit/677c6f8457943fe5b56d7a...
In order to make that fast, I did C++-style generics and inlining in C via the CPP. However, it turned out that GCC does not properly optimize the result, which resulted in the following GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109901 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109901
I suspect things like this happen all of the time in C++ (and by extension, Rust), but developers typically do not look at the assembly output, so they do not notice and bugs are not filed with the compilers. The result is that everyone believes that the compiler will optimize away abstractions, but code can become slower because the compiler is not always able to optimize away the abstractions.
That said, it is awesome when the compiler optimizes away abstraction overhead as expected like LLVM does on that particular code.