The Mpemba effect occurs when a hot system cools faster than an initially colder one, when both are refrigerated in the same thermal reservoir. Using the custom built supercomputer Janus II, we study the Mpemba effect in spin glasses and show that it is a non-equilibrium process, governed by the coherence length xi of the system. The effect occurs when the bath temperature lies in the glassy phase, but it is not necessary for the thermal protocol to cross the critical temperature. In fact, the Mpemba effect follows from a strong relationship between the internal energy and xi that turns out to be a sure-tell sign of being in the glassy phase. Thus, the Mpemba effect presents itself as an intriguing new avenue for the experimental study of the coherence length in supercooled liquids and other glass formers.