Just a couple comments from someone who was been chased by a few dogs:
1) Most of them just want to run alongside the bike, for fun. Not aggressive. For these dogs, dismounting is a great idea, as it will defuse the situation. (Of course, you don't know the dogs' intentions until it is - or is not - attacking you, so this may not always work out well.)
2) Due to #1 above, outrunning the dog is your best bet - then you don't have to guess at its intentions. But with tired legs and a fast dog, this may not be an option.
3) If a dog chases you more than once or twice, call the cops or animal control. They can come talk to the owner, who will hopefully manage the dog more effectively.
I once got nearly knocked off my bike by a dog -- I heard something, and looked over just as the large dog broadsided me. I wobbled a bit, got a foot down, and hollered at the house until the owner came out and got the dog. Then I got on my bike, and discovered the dog had bent the large chainring(!) Dog wasn't injured, miraculously.
PS: Instead of a large stick, just get a long frame pump. Then you've got a weapon AND a pump!