Towards optimality of the parallel tempering algorithm