(PUP-751) Various performance tweaks

The largest performance improvement in here is the change to how
known_resource_types is managed by the compiler. Instead of it constantly
rescanning for any changed files, the scan will only be performed at the start
of a compile run. This alone provides about a 25% improvement. The other small
fixes provide only about another 2% from that point (overall from about 0.8
seconds to 0.58 seconds in the many_modules benchmark).