You should downshift as your cadence starts to drop. Beginners may be advised to shift at the bottom of a hill to avoid getting stuck part way up in too hard a gear. But if you are experienced enough to shift on demand, don't go to an easy gear too soon. If you end up in a slightly too hard gear and need to downshift, put in a couple hard cranks, then slack off on the pedal pressure while you shift (for 1-2 pedal revolutions), then resume normal pedaling. I will typically downshift one or two gears as the hill steepens, then stand for a bit, then sit and downshift again, then stand when my candence starts to fall, then sit and downshift again. Now I'm in my lowest gear (I've only got 12 and only 3-4 lower than my flats gear) so I concentrate on maintaining cadence in that gear, but again stand if my pedal speed falls too much (though the standing gets more and more difficult). This is a workable technique if the hill isn't too too long - luckily my longest hill is only 0.3 miles though fairly steepness. For really long hills, staying seated would be more efficient.