View Issue Details

IDProjectCategoryLast Update
0025704AI War 2Bug - OtherNov 12, 2021 12:37 am
ReporterDaniexpert Assigned ToChris_McElligottPark  
Severityminor 
Status resolvedResolutionfixed 
Product VersionBeta 3.740 Code Panopticon 
Fixed in VersionBeta 3.750 Smooth Simulator 
Summary0025704: perSecondnonSimPlan_LT_Cont idling - Discord discussion
DescriptionLink to the start of the conversation regarding the idle thread, even after pausing/unpausing and reloading a save: https://discord.com/channels/240637654717300736/865219231092310066/903426596499775529

Ending of it:
[01:40] Chris McElligott Park: I don't really know what's causing it, but I'm deciding it probably does not matter.
[01:41] Chris McElligott Park: I think what's actually relevant is if it can self repair, and the answer should be yes.
TagsNo tags attached.

Relationships

related to 0025784 resolvedChris_McElligottPark All threads are idle 

Activities

Daniexpert

Oct 28, 2021 7:47 pm

manager  

Chris_McElligottPark

Nov 5, 2021 9:03 pm

administrator   ~0063238

Thanks!

* After attempting a fairly disastrous tasks-based replacement for our thread-based approach to the main background threads, I've instead started looking into improving the thread-based items.
** First issue: if there's a missing faction or deepinfo as it tries to run LRP, it will have an error (if it gets to that part of the code) and will also show the thread name appropriately. Thanks to tom.prince for the info on this avenue. I don't know if this is solved or not, it's hard to tell just yet.
** Second issue: It is possible for all of the faction threads to be unassigned to a faction. I don't yet know what causes this, but it seems to be repeat loads of various games. Daniexpert first reported it today, and I've seen it once so far. I will have to chase this further on Monday.
*** Reproduction steps: load one savegame twice. Start a new game. Quit to main menu. Load savegame again. Boom.
** Third issue (solved): I never have been able to figure out why the threads seem to kick off so much more frequently than it seems like they should. That in and of itself seems to be a problem. It turns out that I was having these run at sim-speed, and I often play at 5x, so it was doing waaay too much on the background threads. Now it actually uses real time. This may also help with some theoretical issues with gametime-based "last kicked off" logic.
** Fourth issue: for some unknown reason, various non-faction threads sometimes get stuck. Executioncontext is the main one, but there are others. In these cases, Daniexpert was able to log that we get to the "THREAD Kicked next cycle" code.
*** This... is significant, but I'm not quite sure of the nuances why. Essentially, the thread thinks it is done, but has not died or cleaned up. What I now have it doing is killing the thread if the thread has been in this state for at least 4 realtime seconds. I may tighten that down to a substantially smaller margin if it turns out to be messing with the simulation, but I'm not sure on that.
*** Related to this, it looks like the Kill method had a bit of an oversight. If the thread was terminal, then it was not nulling it out and just let things go. Now it nulls it out, which makes the logic above do the proper thing. Or should.
*** Speaking of, if we try to run a thread and it thinks it is complete but still exists, we now check if it's terminal and then null it out if it is. I suspect that when we kill threads by going to the main menu and back into the game, sometimes it was having issues related to being in the terminal state but never nulled. Why this never mattered until recently is a mystery, as this code has not changed much until now.
** Overall I expect things to be improved, and I'd be very interested in which cases still exist in the new code.

Chris_McElligottPark

Nov 12, 2021 12:37 am

administrator   ~0063266

Holy moly, finally fixed. Knock on wood!

Issue History

Date Modified Username Field Change
Oct 28, 2021 7:47 pm Daniexpert New Issue
Oct 28, 2021 7:47 pm Daniexpert File Added: 2021-10-29 01_33_29-AIWar2.png
Nov 5, 2021 7:40 pm Chris_McElligottPark Relationship added related to 0025784
Nov 5, 2021 9:03 pm Chris_McElligottPark Note Added: 0063238
Nov 12, 2021 12:37 am Chris_McElligottPark Assigned To => Chris_McElligottPark
Nov 12, 2021 12:37 am Chris_McElligottPark Status new => resolved
Nov 12, 2021 12:37 am Chris_McElligottPark Resolution open => fixed
Nov 12, 2021 12:37 am Chris_McElligottPark Fixed in Version => Beta 3.750 Smooth Simulator
Nov 12, 2021 12:37 am Chris_McElligottPark Note Added: 0063266