Speaking of scripts, the overall spread is about 88% SS2 scripts (if I'm correct), not counting the GlobalVariable.GetValueInt(). So, just thinking out loud here, something causes one of the frames to wait, while other frames which depend on nested calls are stacked behind it.
This makes sense. If you check CPU usage and i/o during a long save, you'll see that CPU is minimal (less than 5% in my case), and i/o is zero. Since the beginning, I have suspected an active wait problem. Maybe the thread is waiting for some flag that never gets changed, or, as you theorized, some function call loop that eventually gets cleaned in the dump.
My problem with the dump theory is that I have dumps without long saves and long saves without dumps (and dumps with long saves also ofc). Last night when I got the 20k line dump, a few
minutes (not seconds) after fast travel, I felt the engine hang for 2 or 3 seconds. As soon as I felt this, I quicksaved, and it was a fast save (it is in the attachment of my previous post).
I had a crazy idea this morning, but it is a lot of work for the devs.
@kinggath, you can fork the git on the last patch for 1.1.0 and then you merge on that fork the release 2.0.0 and see the changes. Since everything points to the problem being in the scripts, this will show you everything that was changed from the last 'stable' version to the first conflicting one. I suspect this merge will be HUGE, as it will jump over all the internal testing versions you guys had, but the change that caused the problem will be there. It is possible to narrow it down a bit. From my experience, the long saves are caused by building, upgrading and/or scraping plots, especially those that affect virtual storage (industrial and conversion plots and storage containers). None of this is 100% replicable, but it's consistent on my current playthrough (again, the save is closing the three days mark, and it was a new game on the 2.0.0 release). If you are going to do this, I don't know how much the community can help you, as I suspect some internal knowledge of the mod is required to analyze the merge. Anyway, if you are willing to share it, you can count on me taking a look at it.
Trying to narrow down things further, I loaded the required mods / setup for the City Plan Contest together with the latest hotfix.
Placed 2 Asam boxes of plots in one go at Abernathy Farm plus like 15 settlers to start building. Had the same result as previous tests. Maximum save time was 5 to 10 seconds and that where only a few. Most of them <1.
This is so weird. I've tried something similar, and as soon as I placed the first industrial plot (the one from the quest), I got a long save. Other people reported long saves without doing any SS2 content, but I couldn't replicate this. Please keep updating this. Let us know if and when you get a long save