procedural generation – How does Terraria generate such large worlds initially?

I understand how large worlds can be rendered and drawn efficiently by splitting things into chunks, but as I understand it Terraria generates the entire world when you first create it.

The largest world size available in Terraria is 8400 x 2400 which would be a total of 20,160,000 tiles.

Is the entire world generated in one go? Like for example having a large array with 20,160,000 tiles and then saving it to a file when it’s finished? Or would the world generation itself do it chunk by chunk?

Just looking for help to find out what the best method would be to approach this as I’m not really sure.