64 Bit: Why we Need it

darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
edited October 2013 in NS2 General Discussion
(~ I am a bit tired and this is some research I did, let me know if anything is off, and Feel free to correct me. Most is pulled from Microsoft and Wiki)




Why 64 bit will correct a lot of issues with Alec Baldwin.


I will start with the biggest meanest elephant in the room, memory limits of 32 bit OS and applications. Whenever graphics get degraded and your FPS is low, this is why:




- The 4GB Limit

32bit OS and 32 Bit programs like Natural Selection 2 all have a maximum of 4 Gigs. The limit is Max due to running out of addresses to assign(think of it like phone numbers). You would think the 64 bit OS is smart enough to keep infastructure required to run 32bit apps out of the program address space. Nope. Because the 32bit program wouldn't be able see the address in order to communicate with the OS. 32bit apps use 2 GB by default. If the application is large address space aware (linked with /LARGEADDRESSAWARE), it gets 3GB~.




- The Problem

So what are we left with? Nothing. Vram and OS both use ram addressess regaurdless of LAA on. Addresses beyond 4GB dont exist to a 32 bit apps/OS(Think of it like being out of phone numbers, 64bit is like adding an area code). That powerfull vcard with 3 gb of ram? Useless, causing a massive loss in performance. Good CPU? It'll be busy re-mapping addresses to avoid crashing. What the process does when its memory allocations fail. Typically, the program will try to squeeze its use of memory by throwing away anything it doesn't need(Like graphics), unmapping files it wasn't using, and so on. But ultimately, it will simply have to refuse to do things.


The system will map your graphics card into the cpu's address space. 32bit systems can only utilize 4GB at a time, but if it's PAE enabled, the system actually has a 37-bit limit on physical addresses, so depending on how windows virtualizes the ram for a different processes you can effectively use all of it, just not at once.




- Windows Version Dependencies - Why PAE is Never On

http://en.wikipedia.org/wiki/3_GB_barrier#Windows_version_dependencies

"These operating systems do not permit addressing of physical memory above the 4 GB address boundary. This is not an architectural limit; it is a limit imposed by Microsoft. Either the BIOS simply disables the conflicting RAM; or, the BIOS remaps the conflicting RAM to physical addresses above the 4 GB point, but x86 Windows client editions refuse to use physical addresses higher than that, even though they are running with PAE enabled. The conflicting RAM is therefore unavailable to the operating system whether it is remapped or not."


Here is a quote from MSDN explaining:

"Devices have to map their memory below 4 GB for compatibility with non-PAE-aware Windows releases. Therefore, if the system has 4GB of RAM, some of it is either disabled or is remapped above 4GB by the BIOS. If the memory is remapped, X64 Windows can use this memory. X86 client versions of Windows don’t support physical memory above the 4GB mark, so they can’t access these remapped regions. Any X64 Windows or X86 Server release can. X86 client versions with PAE enabled do have a usable 37-bit (128 GB) physical address space.


The limit that these versions impose is the highest permitted physical RAM address, not the size of the IO space. That means PAE-aware drivers can actually use physical space above 4 GB if they want. For example, drivers could map the "lost" memory regions located above 4 GB and expose this memory as a RAM disk."










REAL (not the troll version lol) TLDR:

On 64 bit, 32 bit applications can assign 2^32 = 4294967295(4GB) memory addresses (w/LAA) just like a 32bit OS, this max NEVER changes. Vram also uses addresses from the same pool. So you got windows adding its stuff(takes about 0.5~GB), the game, and VRAM. All eating the same 4gb address limit.


Why can't windows and VRAM use the free space on the 64 bit side? The 32 bit application wouldn't know they existed if something got assigned outside the programs 4294967295 possible memory addresses. So it has to stay within the limit of 4gb.


Example:

The old phone numbers were 7 digits XXX-XXXX(32bit). If an area issues all the phone numbers, it obviously can't issue anymore without using the same ones twice. So an area code is implemented, 3 more digits are added (123)456-789X. This is what 64bit does by increasing addresses to 16,000,000,000,000,000,000 or 16 exbibytes vs 4GB of RAM. If "Mr. 32bit CPU" has an old phone that only allows 7 digits. He can't never call someone with an area code until he gets a newer one from "Ms. 64 bit". lol
«1

Comments

  • AurOn2AurOn2 COOKIES! FREEDOM, AND BISCUITS! Australia Join Date: 2012-01-13 Member: 140224Members, Forum Moderators, NS2 Playtester, Forum staff
    well, if you put it that way.. well.. problem is.. its not easy to turn a 32bit app to a 64 bit app, theres no switch that item to this item. Don't get me wrong, i'd love it to be there, but Just probably not possible for uwe to do it, at the moment, maybe not ever.
  • hub3rtu2hub3rtu2 Join Date: 2012-11-01 Member: 165478Members, Reinforced - Diamond
    The problems are caused by memory fragmentation, not lack thereof. NS2 won't use your pretty 3GB+ RAM when it gets optimized or there at least will be an option to turn off the extra stuff, riiiiiight UWE?
    Another thing is, going 64bit is probably not easy and there would probably be problems with drivers/OS/display compatibility. We have enough bugs as it is.
    Also, they can't just leave 32bit, because that's the minimal system requirement they revealed on release. Otherwise they would have to return the money or something.

    Anyways, they will fix it on their own, I want to believe.
    PUxTT.gif
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    Creating 64-bit binaries is as simple as flipping a switch if your code is not crap, but the problem are 3rd party libraries...

    As for memory usage: One round of ns2_veil causes a peak of 1.7/2.1/1.6 GB (private bytes, virtual size, working set).

    So no, the system requirements are not right and no system with 1/2 GB even of free RAM will be able to run this game.
  • Omega_K2Omega_K2 Join Date: 2011-12-25 Member: 139013Members, Reinforced - Shadow
    There is no need for 64bit, it won't magically make the game run better or anything. And it's not THAT heavy on memory
  • AsranielAsraniel Join Date: 2002-06-03 Member: 724Members, Playtest Lead, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow, Subnautica Playtester, Retired Community Developer
    The memory problem also affects 64 bit, its an issue on how the memory is managed, not how much is used. once thats sorted out (and its in the process of beeing sorted out, but it takes time) then all will be fine.
    64 bit does have other advantages though. If you compile your executables for 64bit, the compiler will autoamtically be able to use certain features of the CPU like SSE 4 etc, because he knows those features are present. By default with 32bit those advanced features are not used. So yes, move to 64 bit, but not just for ns2
  • Omega_K2Omega_K2 Join Date: 2011-12-25 Member: 139013Members, Reinforced - Shadow
    Asraniel wrote: »
    The memory problem also affects 64 bit, its an issue on how the memory is managed, not how much is used. once thats sorted out (and its in the process of beeing sorted out, but it takes time) then all will be fine.
    64 bit does have other advantages though. If you compile your executables for 64bit, the compiler will autoamtically be able to use certain features of the CPU like SSE 4 etc, because he knows those features are present. By default with 32bit those advanced features are not used. So yes, move to 64 bit, but not just for ns2

    SSE4 is a processor instruction set and can be used without 64 bit.

    SSE4 is only available on newer CPUs and if enabled, CPUS without SSE4 won't be able to run NS2. If they want it to be backwards compatible, they need to ship SSE4 and non SSE4 libraries.

    SSE4 may only provide a speed boost IF ns2 actually can make use of any of the instructions provided in the instruction set. If it doesn't, there won't be a difference. Also chances are difference might be neligble.
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    edited October 2013
    Asraniel wrote: »
    The memory problem also affects 64 bit, its an issue on how the memory is managed, not how much is used. once thats sorted out (and its in the process of beeing sorted out, but it takes time) then all will be fine.

    Well, no. The problem is virtual address space. On x86 Windows this is limited to 2 GB (up to 3 GB with the LARGE ADDRESS AWARE switch) per process.

    Typically you cannot re-organize allocated memory blocks because then all pointers would become invalid, so after some time the fragmentation can be high enough to exhaust the virtual address space.

    Look at what I posted above. A round on ns2_veil with ~16 players caused a peak of 2.1 GB virtual memory on my Windows 7 Pro x64 (amd64)! Luckily the limit is 4 GB of virtual address space for 32 bit processes with the switch thanks to amd64, else it would have crashed as well (2 GB limit like with x86)!


    Btw, with 64 bit the limit is 8 TB = 8192 GB. With that you will never run out of virtual address space. So yes, 64-bit would fix the problem.
  • AsranielAsraniel Join Date: 2002-06-03 Member: 724Members, Playtest Lead, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow, Subnautica Playtester, Retired Community Developer
    No it doesn't , there are people reporting the problem on 64 bit (perhaps they dont actually have 16 GB of ram, who knows). Its a bug that just happens less often on 64bit but still will be fixed. 64 bit is superior for many reasons, but not this one
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    Asraniel wrote: »
    No it doesn't , there are people reporting the problem on 64 bit (perhaps they dont actually have 16 GB of ram, who knows). Its a bug that just happens less often on 64bit but still will be fixed. 64 bit is superior for many reasons, but not this one

    Did you understand my reply? Virtual address space is severely limited for 32 bit processes regardless if you're on a x86 or amd64 (x64) OS. Sure, with Windows x64 you get 1 GB more virtual address space but even that extra GB may be exhausted due to fragmentation.

    64 bit processes are virtually unlimited.

  • SamusDroidSamusDroid Colorado Join Date: 2013-05-13 Member: 185219Members, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Gold, Subnautica Playtester, NS2 Community Developer, Pistachionauts
    It's still possible to get a crash with failed memory allocation on 8gb ram with 64bit, if you really try. Was messing around stress testing the game,and let's just say I created enough whips hives crags and then arced them. Well...that was awesome to say the least before it crashed. Was running good before though :P
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    edited October 2013
    It doesn't matter how much RAM you have. There's still the 4 GB virtual address space limit for 32 bit processes.

    Even if you had 8 GB free RAM, a 32 bit process could still fail allocating a chunk that is only a couple of megabytes big.


    With the latest patches the crashes are a lot rarer on my system. The optimizations are quite noticeable and kinda annoying though: extremely blurred textures until the higher resolution ones are loaded, missing sprites .. until they finally get loaded, etc.

    I'd really prefer a build where all of that could be loaded when the map is loaded, so that no on-demand loading needs to be done during a play. Quite annoying when you get that nasty FPS drop on the first marine/alien encounter because something needs to be loaded on demand..
  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    SamusDroid wrote: »
    It's still possible to get a crash with failed memory allocation on 8gb ram with 64bit, if you really try. Was messing around stress testing the game,and let's just say I created enough whips hives crags and then arced them. Well...that was awesome to say the least before it crashed. Was running good before though :P
    xnor wrote: »
    It doesn't matter how much RAM you have. There's still the 4 GB virtual address space limit for 32 bit processes.

    Even if you had 8 GB free RAM, a 32 bit process could still fail allocating a chunk that is only a couple of megabytes big.


    With the latest patches the crashes are a lot rarer on my system. The optimizations are quite noticeable and kinda annoying though: extremely blurred textures until the higher resolution ones are loaded, missing sprites .. until they finally get loaded, etc.

    I'd really prefer a build where all of that could be loaded when the map is loaded, so that no on-demand loading needs to be done during a play. Quite annoying when you get that nasty FPS drop on the first marine/alien encounter because something needs to be loaded on demand..

    Read the OP guys. I have gone over this. :)
  • Omega_K2Omega_K2 Join Date: 2011-12-25 Member: 139013Members, Reinforced - Shadow
    xnor wrote: »
    Did you understand my reply? Virtual address space is severely limited for 32 bit processes regardless if you're on a x86 or amd64 (x64) OS. Sure, with Windows x64 you get 1 GB more virtual address space but even that extra GB may be exhausted due to fragmentation.

    64 bit processes are virtually unlimited.

    64 Bit does NOT resolve the issue, it addresses a symptom of the issue.

  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    edited October 2013
    Asraniel wrote: »
    No it doesn't , there are people reporting the problem on 64 bit (perhaps they dont actually have 16 GB of ram, who knows). Its a bug that just happens less often on 64bit but still will be fixed. 64 bit is superior for many reasons, but not this one

    Hey boss please once over the OP. You might not be entirely correct. Looks like you think 32 bit apps read more memory on 64 bit operating systems. Or I'm reading this wrong. ;/

    TLDR Version

    On 64 bit, 32 bit applications can assign 2^32 = 4294967295(4GB) memory addresses (w/LAA) just like a 32bit OS, this max NEVER changes. Vram also uses addresses from the same pool. So you got windows adding its stuff(takes about 0.5~GB), the game, and VRAM. All eating the same 4gb address limit.


    Why can't windows and VRAM use the free space on the 64 bit side? The 32 bit application wouldn't know they existed if something got assigned outside the programs 4294967295 possible memory addresses. So it has to stay within the limit of 4gb.


    Example:

    The old phone numbers were 7 digits XXX-XXXX(32bit). If an area issues all the phone numbers, it obviously can't issue anymore without using the same ones twice. So an area code is implemented, 3 more digits are added (123)456-789X. This is what 64bit does by increasing addresses to 16,000,000,000,000,000,000 or 16 exbibytes vs 4GB of RAM. If "Mr. 32bit CPU" has an old phone that only allows 7 digits. He can't never call someone with an area code until he gets a newer one from "Ms. 64 bit". lol



    I could be wrong though. Went over 16 hours of material last night tring to understand all of this. I would love a dev to explain in finer detail. I'm interested now. :P
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    edited October 2013
    @darkhunt333: I know, but the OP is long... :P

    @Omega_K2: The real issue is that NS2 needs more virtual memory than 32 bit OS' can provide which is most probably due to the architecture of the engine.

    The on-demand loading we see in this patch (maybe already in the previous patch) is imho a workaround. It's an attempt to only allocate stuff when you absolutely need it, but it will still fail when you need a lot of stuff at roughly the same time... Actually, allocating and freeing stuff all the time could cause more fragmentation in the long run...

    64 bit *would* resolve this issue and also make development easier, because they could just load the stuff on map change, like in older versions, and don't mess around with the on-demand crap.

    As darkhunt333, performance could actually improve too. On my non-SSD system it definitely would, because I get crazy FPS drops everytime the on-demand loading starts..
  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    edited October 2013
    xnor wrote: »
    As darkhunt333, performance could actually improve too. On my non-SSD system it definitely would, because I get crazy FPS drops everytime the on-demand loading starts..


    I rewrote a tldr version for you. I was editing.
  • ScardyBobScardyBob ScardyBob Join Date: 2009-11-25 Member: 69528Forum Admins, Forum Moderators, NS2 Playtester, Squad Five Blue, Reinforced - Shadow, WC 2013 - Shadow
    Personally, I'd love to see a 64-bit version of NS2 so I could use 64-bit versions of other software with NS2 (mostly 64-bit OBS, but also potentially a 64-bit EpicRewind).
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    You forgot that 64bit mode would also give the game more CPU registers. More registers = more fun!
  • MB42MB42 Join Date: 2013-09-07 Member: 187923Members
    ROFL - all the geniuses saying that NS2 won't run with this that or the other thing. Perhaps what you really meant to say was "it won't run well".
    I'm running XP 32 bit, 4Gb, Intel Core 2 Duo E6600 Conroe 2.4GHz.
    NS2 runs fine 75 percent of the time now on build 257 but it will eventually crash. *Which is expected given the "memory management fragmentation" issues.
    PS - (in case you read any of my other posts) I do plan to upgrade to Win 7 64.
  • 1dominator11dominator1 Join Date: 2010-11-19 Member: 75011Members
    edited October 2013
    But then I have to replace an OS that has never had any trouble running any game Ive chosen to play (up to and including modern games like RTW2). Any game that is until this reinforced came out.
    I just wish they would add an option to disable female marine model, that seems to be the biggest memory hog what with it having its own complete set of distinct animations. Also upgrading NS2 to 64bit might be bloody hard.
  • ezekelezekel Join Date: 2012-11-29 Member: 173589Members, NS2 Map Tester
    steam isn't even 64bit :P
  • xnorxnor Join Date: 2013-09-06 Member: 187916Members, Reinforced - Gold
    ezekel wrote: »
    steam isn't even 64bit :P
    What Steam is or isn't is completely irrelevant.
  • DC_DarklingDC_Darkling Join Date: 2003-07-10 Member: 18068Members, Constellation, Squad Five Blue, Squad Five Silver
    well while it wont hurt for games to be 64 bit in the long term, some games already make 64b clients, its unfair to see it as the only solution.

    I have experienced weird... lag and latency spikes when my ns2 was pushing 2GB~ so perhaps those problems are mem related also. (yes, latency.. perhaps its slow down after the packets are received or something)

    Also I just realised. Addons add more stuff and may very well push someone over the limit faster
  • Omega_K2Omega_K2 Join Date: 2011-12-25 Member: 139013Members, Reinforced - Shadow
    edited October 2013
    xnor wrote: »
    @Omega_K2: The real issue is that NS2 needs more virtual memory than 32 bit OS' can provide which is most probably due to the architecture of the engine.

    The on-demand loading we see in this patch (maybe already in the previous patch) is imho a workaround. It's an attempt to only allocate stuff when you absolutely need it, but it will still fail when you need a lot of stuff at roughly the same time... Actually, allocating and freeing stuff all the time could cause more fragmentation in the long run...

    64 bit *would* resolve this issue and also make development easier, because they could just load the stuff on map change, like in older versions, and don't mess around with the on-demand crap.

    As darkhunt333, performance could actually improve too. On my non-SSD system it definitely would, because I get crazy FPS drops everytime the on-demand loading starts..

    On a 32 bit windows yes, but that's the problem of the end user if he has enough ram but not running the appropinate system.
    On 64bit windows you have more virtual space available up to the known 4gigs.


    Problem with NS2 is that keeps using more memory without freeing memory which is why it eventually crashes. That's not a 32 bit or 64 bit or whatever bit problem, it's an issue with the code. What's happening here is that memory does not get deallocated:

    Think of it like this:
    (X = used, [ ] = free, U unused)
    Memory blocks
    [X] [ ] [X] [ ]
    [X] [ ] [U] [X]
    [X] [X] [U] [U]
    
    -> crash, no more free memory, "lots of memory usage"


    64 bit would resolve an issue if NS2 actually would need more then 4 GB of virtual memory. Thing is it doesn't necessarily need that much.


    Now you're reffering to more or additional caching, in which's case 64 bit might make sense, so they can cache more. But you'd still have to do on-demand loading, unless you have shitloads of memory available, it's good to have on demand loading, or why would you need descent textures in memory if you haven't played descent for 10 rounds? Unless they'd change the requiremens of NS2 to 64 bit os, 16GB of ram and a gfx card with 3GB VRAM, a bold move to finally kill NS2 userbase (except the hardcore gamers that have high end systems already).
    They still need to do on-demand loading, especially for lower end systems with less memory.
  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    Omega_K2 wrote: »
    Problem with NS2 is that keeps using more memory without freeing memory which is why it eventually crashes. That's not a 32 bit or 64 bit or whatever bit problem, it's an issue with the code. What's happening here is that memory does not get deallocated:

    I wrote you a nice reply. It needs to be reviewed or something. :S
  • maD_maX_maD_maX_ Join Date: 2013-04-07 Member: 184678Members
    @omega_k2 maybe this is a silly question, but what's the difference between unused and free [ ]...
  • darkhunt333darkhunt333 Join Date: 2012-11-01 Member: 165414Members, Reinforced - Shadow
    edited October 2013
    xnor wrote: »
    As for memory usage: One round of ns2_veil causes a peak of 1.7/2.1/1.6 GB (private bytes, virtual size, working set).


    What you see in task manager only shows RAM usage. VRAM requires a 3rd party program to see its usage. VRAM adds to the 32bit address limit. Windows also adds 0.5 GB to the address limit.


    Someone thought because Microsoft fixed the problem that caused all addresses on VRAM to be written to RAM as well. Now it only writes to the VRAM giving the impression that you can use more ram. It increased performance in some areas. In reality if you shift more load to the VRAM more RAM will become available, but it will not usable. It would have to increase the 4294967295 32bit memory address limit shared between the OS, VRAM, and RAM. Only 64 and special server CPUs with PAE enabled can achieve this


    With 32 bit, If you want some M&M chocolate cake, you will have to give up some of your vanilla ice cream cake.
    With 64 bit, you can have your cake, and eat it too. :D



    EDIT:
    Whoa a dev.
  • zimzumzimzum Join Date: 2004-09-02 Member: 31200Members, Reinforced - Shadow
    Whoa a dev

    and more importantly, an answer to your question/statement/demands..
    Dushan and I are currently putting all of our efforts into addressing (no pun intended) the memory issues. However, we're not planning on releasing a 64-bit build until we can completely abandon 32-bit (i.e. not for Natural Selection 2, but probably the next game we release).
  • majorpainmajorpain Join Date: 2013-09-01 Member: 187515Members
    @Max
    Thanks for the update, nice to know your actually getting somewhere with this, been feeling like you just gave up.
Sign In or Register to comment.