For anybody new coming across this. the fix for me was a combination of things, before which the generating optimised autoload files took over 260s.
First adding : "https://packagist.org" to repositories in composer.json.
"repositories": [ { "type": "composer", "url": "https://packagist.org" } ]
then
composer clear-cache
composer update
then
composer install -vvv --profile
(took about 115 secs) ran after this and its now 20s
composer install -vvv --profile