All modern engines have Knock Sensors. They detect the detonation in the engine and will retard (or advance) timing based on the "sounds" of the engine. If you run a higher octane the detonation will decrease and the timing can be advanced which would allow the engine to perform slightly different.
