How to prevent organization/OS students from becoming premature optimizers? While I'm sure that the comp-sci 101 mistake of having a triple nested loop with two recursive calls is sure to be cured by a decent comp-org class, it can have the unintended side-effect of turning students, enlightened by this hidden knowledge of registers and memory management, become obsessive about unrolling loops in trivial ways and trying to out-O3 the compiler like it's ($CURRENT_YEAR - 40).

What is the prevention to this error of learning in the course of teaching the subject? I doubt that most students will ever be in a situation where there will be a difference caused by writing something like struct baz{char a; int z; char b;};.
I'm honestly not that I would address this problem at all within my own courses, but if it is to be faced, I suspect that the solution would be something like this:


Immerse students in their current layer.
Really teach the metaphor and thought-process of the layer that they are currently in, and only accept code that utilizes that model of thinking.
Warn students about the dangers of premature optimizing
Show students how to use a profiler in order to figure out what is actually slowing their code down.  Tell students to address their efforts here.