Finding how fast L1 cache is compared to memory access

I tried my hand at inline assembly in Rust. Feedback on code/content is welcome :slight_smile:

Fun little read! It’s nice to see some inline assembly in action, and you give good explanations for all the arguments and their role!

I do have two suggestions:

  1. clobbers

I really love this word, and personally think it is one of the best-fitting names in programming.
However, it is a fairly ‘non-standard’ word in the English language, so especially for non-native speakers, it might be useful to include a dictionary definition, e.g. Merriam-Webster says

1.) to pound mercilessly
2b) to have a strongly negative impact on

(So, the “clobber” definition has always sounded to me like the program threatening “Compiler, I’m about to do merciless things to these registers. Stay away!”, an image that fits nicely with the dark magicks of writing assembly)

  1. because the assembly code is not optimized by the compiler

I believed this as well, but was once told this isn’t true, by someone who seems far more knowledgeable than I am. I’m still not sure what to believe.
It was mentioned in this stack-overflow Q&A comment, maybe you can make more sense of it?

User Matthias: … As you can try for yourself, the optimiser even touches this assembler code. …

1 Like

Thanks for the feedback :slight_smile:

  1. That’s how I understood clobbers too :smiley: It’s really an appropriate word for this case.
  2. This is surprising to me. I thought a compiler optimizes in the intermediate representation and then produces the target specific machine code. Now I see that this was a simplistic view and compilers can and do also optimize assembly.
1 Like