(Suggestion) 4gb large address (fix lag)

(previously 'DEVELOPER') Private forum for registered community members. To register, please visit www.prison-architect.com/register.

Moderator: NBJeff

xPyr0x
level2
level2
Posts: 190
Joined: Sun Sep 21, 2014 2:13 am
Location: United States

(Suggestion) 4gb large address (fix lag)

Postby xPyr0x » Tue Sep 30, 2014 1:36 pm

Skyrim, oblivion, and the list goes on. All were plagued by maxing the amount of ram a 32bit exe could load. But on 64 bit OS The problem (usually extreme lag or crashes) could be fixed. Perhaps this can be applied to Prison Architect and will help with the lag on bigger prisons.

I found this app available that claims to work on any executable, but it just causes prison architect to fail to launch. http://www.ntcore.com/4gb_patch.php.
xPyr0x
level2
level2
Posts: 190
Joined: Sun Sep 21, 2014 2:13 am
Location: United States

Re: (Suggestion) 4gb large address (fix lag)

Postby xPyr0x » Tue Sep 30, 2014 1:59 pm

Ok it doesn't work with the steam version. But it works with the drm free version you can get off the website or from humbles page. Unknown if it will change anything performance wise, but I'll update this post if it does.
MFWIC
level2
level2
Posts: 139
Joined: Sat Apr 19, 2014 9:02 pm

Re: (Suggestion) 4gb large address (fix lag)

Postby MFWIC » Mon Oct 06, 2014 12:34 am

I didn't see an appreciable difference in one of my giant prisons. (1,200 prisoners, 450 guards, 30 dogs, 100 cooks, 20 gardeners, 80 armed guards, 20 janitors, 50 workers)
xPyr0x
level2
level2
Posts: 190
Joined: Sun Sep 21, 2014 2:13 am
Location: United States

Re: (Suggestion) 4gb large address (fix lag)

Postby xPyr0x » Mon Oct 06, 2014 2:03 am

Yeah neither did I, no notice in performance increase. But thats because the game is only using 1 core, and worse, loading your entire prison from 1 giant text file... Using that patch also produced problems like unable to save and such, on alpha 24, so I stopped using it. But I've seen my 1000 prisoner prison use the max amount of ram, and it runs at a staggering 3-10 fps, the lag is so unbearable that it won't even register mouse clicks, and fast mode, the game appears to just ignore and runs in slow motion anyway.

I've simply stuck to using the small map, and the less total items in your prison, the less it lags. Only thing we can do until the devs fix the lag.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Re: (Suggestion) 4gb large address (fix lag)

Postby xander » Mon Oct 06, 2014 2:45 am

xPyr0x wrote:But thats because the game is only using 1 core...

This again? In fact, Prison Architect uses at least two threads (one for path-finding, one for everything else). It is conceivably possible that spreading the path-finding across more threads could improve performance some, but the gains would very quickly be swamped by the complexity of the problem (essentially, the complexity is exponential while the addition of a new thread is at best linear).

xPyr0x wrote:...and worse, loading your entire prison from 1 giant text file.

I don't see how this would make any difference at all. What matters is the internal representation of the game. The text file that is saved to disk is only going to cause problems when it is being read (which happens once when the game is loaded) or being written to (which happens whenever the game is saved, either manually or automatically).

xPyr0x wrote:But I've seen my 1000 prisoner prison use the max amount of ram...

There is probably some optimization that needs to be done with regard to how much information is remembered (do we need to remember every bit of contraband ever? probably not), and it is likely that this will happen at some point. That being said, I propose an alternative solution: simply limit the total number of units that a player is allowed to have. Once a prison hits (for instance) 1000 prisoners, stop delivering prisoners. Once a player has hired (for instance) more than 1000 staff, don't let them hire more. It may seem like a gamey limitation, but I've been playing Starcraft for more than a decade with more severe unit limitations.

xander
xPyr0x
level2
level2
Posts: 190
Joined: Sun Sep 21, 2014 2:13 am
Location: United States

Re: (Suggestion) 4gb large address (fix lag)

Postby xPyr0x » Mon Oct 06, 2014 3:14 am

I don't understand how it works Xander, all I know is the 4gb patch has fixed a lot of other games. The bigger the prison, or mass amounts of items = more lag.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Re: (Suggestion) 4gb large address (fix lag)

Postby xander » Mon Oct 06, 2014 3:34 am

xPyr0x wrote:I don't understand how it works Xander, all I know is the 4gb patch has fixed a lot of other games.

I have no idea what the patch does. At a guess, I suspect the following: the patch somehow allows a program to address more than the amount of RAM that would normally be allocated (perhaps because the program was compiled as a 32-bit, rather than 64-bit, binary). If a game is running up against the limit of how much RAM has been allocated, then it will have to start swapping data to disk (basically using a hard drive or SSD as RAM). RAM can be read and written at least an order of magnitude faster than a disk, hence any time that a program is forced to use disk space as RAM, things will slow down.

*If* this patch allows a program to use more RAM, then the problem that Prison Architect is having *is not* that it doesn't have access to enough memory but (as noted above) that IV are keeping track of too much stuff. The correct solution is not to allocate more RAM, but to optimize the game so that it doesn't need so much RAM.

xander
MFWIC
level2
level2
Posts: 139
Joined: Sat Apr 19, 2014 9:02 pm

Re: (Suggestion) 4gb large address (fix lag)

Postby MFWIC » Mon Oct 06, 2014 11:06 pm

The game being in an alpha state I'm quite sure there's a lot of optimization that could be done. Back in my school days it took me 90 lines of code to do what I can now reduce to three or four after a few version cycles.
BGK
level1
level1
Posts: 13
Joined: Mon Sep 29, 2014 11:36 pm
Location: France

Re: (Suggestion) 4gb large address (fix lag)

Postby BGK » Tue Oct 07, 2014 12:45 am

xander wrote:If a game is running up against the limit of how much RAM has been allocated, then it will have to start swapping data to disk (basically using a hard drive or SSD as RAM). RAM can be read and written at least an order of magnitude faster than a disk, hence any time that a program is forced to use disk space as RAM, things will slow down.


That's not how things work, at all.

You swap when the whole system is running out of physical memory, meaning some programs want to allocate memory but none is available (ex: you have 16GB of RAM, all of it already used by other programs), hence some disk space (swap area) is used instead.

Depending of the quality of the code and the type of language used, a program that is running out of memory addresses (2GB limitation for 32Bits exe) will either:
- Crash (dirty) with some "out of memory" message (message provided by the OS)
- handle the memory problem internally, (clean) close itself and displaying the exact issue to the user
- try to free memory (internal), remove unused data from its memory addresses (example: hard call of some garbage collector), will probably start lagging at this point.
learn_more
level1
level1
Posts: 36
Joined: Sun Sep 07, 2014 9:18 pm

Re: (Suggestion) 4gb large address (fix lag)

Postby learn_more » Wed Oct 08, 2014 10:25 pm

xander wrote:
xPyr0x wrote:I don't understand how it works Xander, all I know is the 4gb patch has fixed a lot of other games.

I have no idea what the patch does. At a guess, I suspect the following: the patch somehow allows a program to address more than the amount of RAM that would normally be allocated (perhaps because the program was compiled as a 32-bit, rather than 64-bit, binary). If a game is running up against the limit of how much RAM has been allocated, then it will have to start swapping data to disk (basically using a hard drive or SSD as RAM). RAM can be read and written at least an order of magnitude faster than a disk, hence any time that a program is forced to use disk space as RAM, things will slow down.

*If* this patch allows a program to use more RAM, then the problem that Prison Architect is having *is not* that it doesn't have access to enough memory but (as noted above) that IV are keeping track of too much stuff. The correct solution is not to allocate more RAM, but to optimize the game so that it doesn't need so much RAM.

xander


the tool simply sets the 'large address aware' bit in the exe file header.
it's the same as using this option:
http://msdn.microsoft.com/en-us/library/wz223b1z.aspx

this will only work if the game treats pointers correctly,
and it will only have effect if the game runs out of memory (e.g. needs more then 2GB)
nothing to do with swapping to disk ;) (that is related to the pc running out of _physical_ memory)



ps: why it wont work on the steam version is due to drm.
User avatar
xander
level5
level5
Posts: 16869
Joined: Thu Oct 21, 2004 11:41 pm
Location: Highland, CA, USA
Contact:

Re: (Suggestion) 4gb large address (fix lag)

Postby xander » Thu Oct 09, 2014 4:01 am

BGK wrote:That's not how things work, at all.

There is no need to be condescending, particularly when my post started with the caveat that "I have no idea what the patch does."

xander

Return to “Community Members”

Who is online

Users browsing this forum: No registered users and 13 guests