Some users have reported that their stats compilation operations fail with a PHP out of memory or timeout error.

Look at implementing Batch API to process stats compilation.