Understanding local adaptation and effective population size in the face of complex demographic history