Remove repeated calls to config.stats_enabled.
Remove repeated calls to config.stats_enabled.

Turns out that fetching variables from the config object is expensive,
so doing it once at startup avoids unnecessary work.

matrix-org/synapse,matrix-org/synapse,matrix-org/synapse,matrix-org/synapse,matrix-org/synapse,matrix-org/synapse