Thermodynamic optimization of nanowaveguide sensors