EnglishGermanFrenchRussianItalianSpanish
Log inRegister
 
X3 Complex tree?
Post new topic Reply to topic Goto page Previous  1, 2, 3
View previous topic :: View next topic
Author Message
SirNukes





Joined: 31 Mar 2007
Posts: 147 on topic

Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 01:43    Post subject: Reply with quote Print

Based on the slowdown happening everywhere, not just when heading to/from the complex sector, I took another look through the sector change KC code. The calls to SA_CleanUpObjects and SA_FreeAllBodies take no arguments, implying they look at all sectors in the universe and could be the culprits. So, I tried commenting each of them out and redid the benchmark. SA_FreeAllBodies made no difference, but as for SA_CleanUpObjects ...

256 factory complex, traversing between two empty sectors:
Baseline: 14 seconds
Removing SA_CleanUpObjects: <0.5 seconds.

256x2 factory complex for verification:
Baseline: 75 seconds
Removing SA_CleanUpObjects: <0.5 seconds.

So, there's the culprit. Something is seriously wrong inside SA_CleanUpObjects when dealing with a history of past complexes.

Back to top
View user's profile Send private message
glenmcd





Joined: 16 Oct 2010
Posts: 902 on topic
Location: Australia
Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 03:38    Post subject: Reply with quote Print

Nice work Smile

Back to top
View user's profile Send private message
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)



Joined: 15 Nov 2004
Posts: 20512 on topic
Location: London
Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 11:05    Post subject: Reply with quote Print

SirNukes wrote:
The calls to SA_CleanUpObjects and SA_FreeAllBodies take no arguments, implying they look at all sectors in the universe and could be the culprits.


These commands are part of the sector engine, and they clean up the sector objects when changing sectors, which are only in the active sector, so its only working on a single sector each time.

sector objects and models, etc, only exist in the active sector


_________________
My Scripts | MY X3TC Scripts | X3 Plugin Manager | Custom Gui
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
jlehtone



MEDALMEDALMEDAL

Joined: 23 Apr 2005
Posts: 17025 on topic
Location: GalNet BBS
Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 12:08    Post subject: Reply with quote Print

It is good that there are those, who can see deeper than the rest of us. Thank you.

I can only formulate questions. Embarassed

SirNukes wrote:
traversing between two empty sectors

How did these become empty?

IF SA_CleanUpObjects works only on the objects that are in the (empty) sector that you do leave,
THEN it would be affected only by objects that are there (or were, but have not been properly purged)


What are the baseline (with and without SA_CleanUpObjects) when no (other) sector has a Complex (yet)? In fact, is there a difference on moving between "vanilla empty" sectors and moving between "made empty" sectors?


Logically, there are three events:
A. Clean up current sector (3D) on departure
B. Populate new current sector (with 3D)
C. Update all the OOS

The A and B should not be affected by what is OOS both before and after transition.


Tangent: I've crashed (at the Gate to other ship) when I did jump from sector to the same sector. I presume that the usual "clean up and repopulate" is not performed in that special case. How about the "update factory status"? Does such in-sector jump invoke the C-event?


Polymorphism. NPC Complex is quite different from player Complex. Does same function iterate over all stations for production and stock status, or do player properties have separate function from NPC?


_________________
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.
Back to top
View user's profile Send private message
glenmcd





Joined: 16 Oct 2010
Posts: 902 on topic
Location: Australia
Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 12:16    Post subject: Reply with quote Print

jlehtone wrote:

SirNukes wrote:
traversing between two empty sectors

How did these become empty?


If this refers to my original benchmarking for the balance binary tree complex workaround, I used a script to destruct every object in the two sectors.

Back to top
View user's profile Send private message
SirNukes





Joined: 31 Mar 2007
Posts: 147 on topic

Thank you for registering your game
PostPosted: Sat, 23. Jun 18, 21:35    Post subject: Reply with quote Print

I am indeed using Glen's wonderful saves. The SA_CleanUpObject removal is in my customization tool (a little buried since not for general use), so between the two anyone should be able to verify the measurements I gave.

For reference, here is a summary of my current notes on the key code section in the KC when changing sectors:

  • Do prep work to stop the player ship, stop jumping, close monitors, turn off seta, etc.
  • Call player.LeaveSector, with some light work like rehiding cargo of other sector ships.
  • Call CLIENT.LeaveSector, which will then call Sector.Deactivate, which in turn calls Deactivate on the various sector ships and stations and such. These Deactivate functions are going around calling SA_FreeObject, presumably on the 3d sector object. For instance, complexes will loop over their list of tube information and call SA_FreeObject on the ones with 3d objects (stored in an internal array along with general information recorded from SA_CreateFactoryConnections, which was called at complex creation).
  • Call SA_CleanUpObjects, adding the silly delay.
  • Call SA_FreeAllBodies, adding no noticeable delay.
  • Call CLIENT.EnterSector; basically the reverse of LeaveSector, this goes around calling flavors of Activate functions. For complexes, it is ActivateConnections, which loops over the recorded list of tube information calling stuff like SA_AllocObject (and storing the result for later deactivation), SA_StartObjectInSpace, SA_SetFactoryConnectionParent.
  • Call Player.EnterSector, which deals with stuff like flagging a sector as visited, updating player statistics, etc.
  • Call PLAYER.WarpEnterSector followed by general setup stuff (place the player, turn on monitors, etc.).


So, a couple observations:

My earlier thought that SA_CreateFactoryConnections created tubes feels incorrect, I am now thinking it just returns the necessary info for tube creation (subtype and placement; maintype is always 20), though I haven't picked it all apart yet.

3d object creation/removal appears to be somewhat handled in the KC, which leaves me wondering what would actually happen if I played for a bit with SA_CleanUpObjects disabled. Maybe I'll try that later today.

Back to top
View user's profile Send private message
SirNukes





Joined: 31 Mar 2007
Posts: 147 on topic

Thank you for registering your game
PostPosted: Sun, 24. Jun 18, 02:49    Post subject: Reply with quote Print

I spent about an hour with SA_CleanUpObjects removed on my XRM save, puttering around some sectors, doing some fighting, then doing a fast tour of a bunch of sectors. Everything played out normally.

In case stale objects were building up, I watched the X3 memory usage and checked the save game size. Memory usage was stable, growing up to ~3.5 GB and then cleaning out old data to go back to ~1.8 GB, growing again with more sectors visited and objects loaded. This is the same behavior as normal. Save game size at the end was similar to (slightly smaller than) when started.

Another test used the 256-factory complex save, this time popping through the gate to the complex sector repeatedly to see if there might be some object buildup. Memory usage was stable, suggesting no buildup.

So, right now, the only obvious effect SA_CleanUpObjects appears to have is adding sector exit delay for games with big complexes. Interestingly, this function is not in the X2 KC documentation, so that game appears to have made do without it.

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic Reply to topic Goto page Previous  1, 2, 3
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Sat, 21. Jul 18, 09:25

All times are GMT + 2 Hours

[ Disclaimer / Impressum ] | [ Privacy Policy / Datenschutz ]

Board Security

Copyright © EGOSOFT 1989-2018
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.07628 seconds, sql queries = 21