I understand that, on the PC (x86-64), using -Ctarget-cpu=native allows the compiler to use AES-NI, which certainly gives a big boost to my code that builds upon the AES block cipher.
Still, why is the macOS build so much slower, even in the "default" case?
Also, doesn't the Apple M2 CPU support ARM Crypto instructions that should accelerate AES computations in the -Ctarget-cpu=native case? But, apparently, on macOS, using adding the -Ctarget-cpu=native option to RUSTFLAGS doesn't make any difference at all...
So, is rustc just not optimized that well for Apple Silicon, or am I missing something here?
Yes, Rust aes should support AES-NI and ARMv8 intrinsics.
BTW: The documentation talks about an "aes_armv8" feature, but this does not seem to exist, neither as a crate feature nor as a -Ctarget-feature option in RUSTFLAGS
Nonetheless, the graph shows that aes::armv8::expand::expand_key is used on macOS.
If you want to dig into where the performance issues are you'll need to do some instruction-level profiling. The Instruments tool in XCode is probably the easiest way do do that on macOS.
Since I'm not an expert in assembler code nor a compiler developer, I don't even know what I would be looking for, or how this could help me to resolve the performance issue...
Actually, I'm already using version 0.9.0-rc.2, because version 0.8.x has a dependency on "generic-array" (version 0.x), which is now deprecated and causes many deprecation warnings.