Irreversibility of mechanical and hydrodynamic instabilities